diff --git a/src/execution/execution.c b/src/execution/execution.c index cf751f7..be3b378 100644 --- a/src/execution/execution.c +++ b/src/execution/execution.c @@ -40,6 +40,8 @@ int execution(struct ast *ast, struct hash_map *vars) return exec_ast_list(ast_get_list(ast), vars); case AST_AND_OR: return exec_ast_and_or(ast_get_and_or(ast), vars); + case AST_ASSIGNMENT: + return exec_ast_assignment(ast_get_assignment(ast), vars); default: return 127; } diff --git a/src/execution/execution_helpers.c b/src/execution/execution_helpers.c index 9e44dfa..c77c9b3 100644 --- a/src/execution/execution_helpers.c +++ b/src/execution/execution_helpers.c @@ -203,6 +203,13 @@ int exec_ast_command(struct ast_command *command, struct hash_map *vars) return 1; } + +int exec_ast_assignment(struct ast_assignment *assign, struct hash_map *vars) +{ + set_var_copy(vars, assign->name, assign->value); + return 0; +} + int exec_ast_if(struct ast_if *if_node, struct hash_map *vars) { int cond = execution(if_node->condition, vars); diff --git a/src/execution/execution_helpers.h b/src/execution/execution_helpers.h index 622c9fe..9fbe90a 100644 --- a/src/execution/execution_helpers.h +++ b/src/execution/execution_helpers.h @@ -8,7 +8,7 @@ int exec_ast_command(struct ast_command *command, struct hash_map *vars); int exec_ast_if(struct ast_if *if_node, struct hash_map *vars); int exec_ast_list(struct ast_list *list_node, struct hash_map *vars); int exec_ast_and_or(struct ast_and_or *ao_node, struct hash_map *vars); +int exec_ast_assignment(struct ast_assignment *assign, struct hash_map *vars); void unset_all_redir(struct list *redir_list); - #endif // EXECUTION_HELPERS_H