diff --git a/inc/tokens.h b/inc/tokens.h index fd633cdb..d1e3dcb1 100644 --- a/inc/tokens.h +++ b/inc/tokens.h @@ -91,9 +91,8 @@ void execute_command(char **parsed_text, t_token **tokens); void print_maxishell(void); int input_error_checks(t_loop_data *loop_data); t_token *tokenise(char *str); -void print_tokens(t_token *tokens); +void print_tokens(t_token *tokens, char *name); t_ast *parse_tokens(t_token **tokens, t_ms_data *data); -void print_tokens(t_token *tokens); void visualize_ast(t_ast *root); void free_ast(t_ast *node); void free_all_tokens(t_token *tokens); diff --git a/minishell b/minishell new file mode 100755 index 00000000..55626851 Binary files /dev/null and b/minishell differ diff --git a/src/check_tokenise/tokeniser_helpers.c b/src/check_tokenise/tokeniser_helpers.c index 1eaf228d..34410918 100644 --- a/src/check_tokenise/tokeniser_helpers.c +++ b/src/check_tokenise/tokeniser_helpers.c @@ -12,20 +12,22 @@ #include "tokens.h" -void print_tokens(t_token *tokens); +void print_tokens(t_token *tokens, char *name); void print_ast_args(t_ast *node); void append_word_if_valid(char *start, char *str, t_token **tokens); -void print_tokens(t_token *tokens) +void print_tokens(t_token *tokens, char *name) { t_token *token; int i; i = 0; token = tokens; + if (ft_strlen(name) > 0) + ft_printf(GRN"----- %s[] -----\n"RESET, name); while (token != NULL) { - ft_printf("input[%d] -> %s at add: %p\n", \ + ft_printf(GRN"input[%d] -> %s at add: %p\n"RESET, \ i, token->data, &token->data); token = token->next; i++; diff --git a/src/parser/AST_utils.c b/src/parser/AST_utils.c index 2ac631ee..e1829454 100644 --- a/src/parser/AST_utils.c +++ b/src/parser/AST_utils.c @@ -82,6 +82,7 @@ t_ast *manage_commands(t_token **tokens, t_ms_data *data) return (NULL); set_command_args(command_node, tokens, cmd_arg_count); post_process_command_args(command_node, cmd_arg_count, data); + // ft_print_2d_arr(command_node->args, "manage_commands, after ppca"); return (command_node); } diff --git a/src/parser/loc_env_var_handler.c b/src/parser/loc_env_var_handler.c index 586c33d0..0948c318 100644 --- a/src/parser/loc_env_var_handler.c +++ b/src/parser/loc_env_var_handler.c @@ -76,11 +76,20 @@ void post_process_command_args(t_ast *command_node, int arg_count, \ processed_arg = ft_substr(command_node->args[i], 1, \ ft_strlen(command_node->args[i]) - 2); free(command_node->args[i]); + ft_printf("processed_arg: %s\n", processed_arg); + processed_arg = ft_remove_quotes(processed_arg, '\"'); + ft_printf("processed_arg: %s\n", processed_arg); split_loc_vars(command_node, processed_arg, ¤t_size, &i); free(processed_arg); } command_node->args[current_size] = NULL; - final_quote_removal(current_size, command_node); + for (i=0; i < current_size; i++) + { + command_node->args[i] = ft_remove_quotes(command_node->args[i], '\"'); + } + + //final_quote_removal(current_size, command_node); + ft_print_2d_arr(command_node->args, "ppca after final-quote_removal"); } char *append_expanded_var(char *processed_arg, char *tmp_ad, \ diff --git a/src/parser/loc_env_var_handler_utils_utils.c b/src/parser/loc_env_var_handler_utils_utils.c index 2fae69f9..063bad47 100644 --- a/src/parser/loc_env_var_handler_utils_utils.c +++ b/src/parser/loc_env_var_handler_utils_utils.c @@ -26,6 +26,7 @@ void final_quote_removal(int arg_count, t_ast *command_node) char *trimmed_arg; i = 0; + ft_print_2d_arr(command_node->args, "final-quote_removal"); while (i < arg_count) { arg = command_node->args[i]; diff --git a/tokens); b/tokens); new file mode 100644 index 00000000..e69de29b