diff --git a/sources.mk b/sources.mk index 917112d..dab7129 100644 --- a/sources.mk +++ b/sources.mk @@ -1,27 +1,27 @@ -VPATH = src:src/parser:src/environment:src/lexer:src/redirect:src/debug:src/token:src/signal:src/prompt:src/utils:src/expander:src/executor:src/builtin: -SOURCES = parser_validate_command.c parser_get_arguments.c \ -parser_alloc_command.c parser_create_command.c parser_get_commands.c \ -environment_get.c environment_get_arr.c environment_free_list.c \ -environment_update.c environment_add.c environment_print.c \ -environment_del.c environment_free.c environment_parse.c lexer_new.c \ -lexer_read_word.c lexer_read_char.c lexer_parse_input.c \ -lexer_parse_quotes.c lexer_token_next.c redirect_get_inputs.c \ -redirect_get_outputs.c redirect_new.c redirect_valid_type.c \ -redirect_new_error.c redirect_process_heredoc.c print_freelist.c \ -print_commands.c main.c token_new.c token_char_convert.c \ -token_parse.c token_type_convert.c signal_init.c.c signal.c \ -history_write.c prompt.c history_load.c free_command_list.c \ -free_minishell.c ft_lstnew_safe.c free_safe.c free_lexer.c \ -ft_free_arr_safe.c print_banner.c check_malloc.c free_freelist.c \ -ft_lstclear_safe.c ft_split_safe.c error_msg.c free_token_list.c \ -malloc_safe.c free_minishell_line.c ft_strdup_safe.c free_token.c \ -ft_substr_safe.c init_minishell.c ft_strjoin_safe.c \ -expander_allocate_memory.c expander_parse_string.c \ -expander_parse_variables.c expander_expand_dollar.c \ -expander_is_character.c expander_get_variable.c executor_open_fds.c \ -executor_count_fds.c executor_fork.c executor_absolute_path.c \ -executor_execute_pipeline.c executor_child.c executor_close_fds.c \ -executor_create_redirects.c executor_create_pipes.c builtin_export.c \ -simple_builtins.c builtin_router.c is_builtin.c builtin_unset.c \ -builtin_env.c builtin_cd.c builtin_pwd.c builtin_exit.c \ -builtin_echo.c \ +VPATH = src:src/prompt:src/utils:src/lexer:src/token:src/environment:src/executor:src/parser:src/signal:src/debug:src/expander:src/builtin:src/redirect: +SOURCES = history_write.c history_load.c prompt.c check_malloc.c \ +free_freelist.c free_lexer.c free_safe.c free_token.c \ +free_token_list.c ft_lstclear_safe.c ft_lstnew_safe.c \ +ft_strjoin_safe.c free_minishell_line.c ft_substr_safe.c \ +ft_split_safe.c init_minishell.c print_banner.c ft_free_arr_safe.c \ +error_msg.c free_command_list.c ft_strdup_safe.c malloc_safe.c \ +free_minishell.c lexer_read_char.c lexer_new.c lexer_parse_quotes.c \ +lexer_parse_input.c lexer_read_word.c lexer_token_next.c token_new.c \ +token_char_convert.c token_parse.c token_type_convert.c \ +environment_del.c environment_free.c environment_get.c \ +environment_free_list.c environment_parse.c environment_add.c \ +environment_get_arr.c environment_print.c environment_update.c \ +executor_close_fds.c executor_open_fds.c executor_count_fds.c \ +executor_create_pipes.c executor_create_redirects.c executor_fork.c \ +executor_execute_pipeline.c executor_absolute_path.c executor_child.c \ +parser_create_command.c parser_validate_command.c \ +parser_alloc_command.c parser_get_commands.c parser_get_arguments.c \ +parser_sanitize_string.c signal.c signal_init.c.c print_freelist.c \ +print_commands.c expander_expand_dollar.c expander_is_character.c \ +expander_parse_variables.c expander_get_variable.c \ +expander_allocate_memory.c expander_parse_string.c builtin_unset.c \ +builtin_pwd.c builtin_cd.c builtin_echo.c builtin_env.c \ +builtin_exit.c builtin_export.c builtin_router.c is_builtin.c \ +simple_builtins.c redirect_process_heredoc.c redirect_get_inputs.c \ +redirect_get_outputs.c redirect_new.c redirect_new_error.c \ +redirect_valid_type.c main.c \ diff --git a/src/debug/print_commands.c b/src/debug/print_commands.c index dc04b5f..84a18ec 100644 --- a/src/debug/print_commands.c +++ b/src/debug/print_commands.c @@ -6,7 +6,7 @@ /* By: marvin +#+ */ /* +#+ */ /* Created: 2025/02/18 20:06:37 by qmennen #+# #+# */ -/* Updated: 2025/03/05 12:52:19 by whaffman ######## odam.nl */ +/* Updated: 2025/03/05 13:03:54 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -69,5 +69,8 @@ void token_print(void *param) if (!DEBUG) return ; token = (t_token *)param; - printf( GREEN BOLD "[%s]\t\t" RESET "(%s)\n", token->value, token_type[token->type]); + if (token->type == 11) + printf(RED BOLD "[ERROR]\t\t" RESET "(%s)\n", token_type[token->type]); + else + printf( GREEN BOLD "[%s]\t\t" RESET "{%s(%d)}\n", token->value, token_type[token->type], token->type); } diff --git a/src/executor/executor_execute_pipeline.c b/src/executor/executor_execute_pipeline.c index 5cff6cf..81e9b1b 100644 --- a/src/executor/executor_execute_pipeline.c +++ b/src/executor/executor_execute_pipeline.c @@ -6,7 +6,7 @@ /* By: willem +#+ */ /* +#+ */ /* Created: 2025/02/12 21:25:02 by willem #+# #+# */ -/* Updated: 2025/03/04 18:18:48 by whaffman ######## odam.nl */ +/* Updated: 2025/03/05 13:10:59 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -34,6 +34,14 @@ static int execute_builtin(t_minishell *msh, t_command *cmd) return (exit_status); } +static void executor_execute_command(t_minishell *msh, t_command *cmd) +{ + if (cmd->args[0] != NULL && is_builtin(cmd->args[0]) >= 0) + msh->exit_status = execute_builtin(msh, cmd); + else if (cmd->args[0] != NULL) + executor_fork(msh, cmd); +} + int executor_execute_pipeline(t_minishell *msh) { t_list *current; @@ -47,11 +55,7 @@ int executor_execute_pipeline(t_minishell *msh) last_pid = 0; while (current) { - if (is_builtin(((t_command *)current->content)->args[0]) >= 0) - msh->exit_status = execute_builtin(msh, - (t_command *)current->content); - else - last_pid = executor_fork(msh, (t_command *)current->content); + executor_execute_command(msh, (t_command *)current->content); current = current->next; } if (last_pid != 0)