#define _POSIX_C_SOURCE 200809L #include "execution.h" #include #include #include #include #include #include #include #include #include "../expansion/expansion.h" #include "../utils/ast/ast.h" #include "../utils/hash_map/hash_map.h" // Refactored: delegates to helpers in execution_helpers.c #include "execution_helpers.h" int execution(struct ast *ast, struct hash_map *vars) { if (!ast) return 0; switch (ast->type) { case AST_VOID: case AST_END: return 0; case AST_CMD: { struct ast_command *command = ast_get_command(ast); if (!expand(command, vars)) fprintf(stderr, "Error: Variable expansion failed\n"); return exec_ast_command(command, vars); } case AST_IF: return exec_ast_if(ast_get_if(ast), vars); case AST_LIST: return exec_ast_list(ast_get_list(ast), vars); case AST_AND_OR: return exec_ast_and_or(ast_get_and_or(ast), vars); default: return 127; } }