cmd == NULL fix
This commit is contained in:
parent
32f416694c
commit
d279d27d43
54
sources.mk
54
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:
|
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 = parser_validate_command.c parser_get_arguments.c \
|
SOURCES = history_write.c history_load.c prompt.c check_malloc.c \
|
||||||
parser_alloc_command.c parser_create_command.c parser_get_commands.c \
|
free_freelist.c free_lexer.c free_safe.c free_token.c \
|
||||||
environment_get.c environment_get_arr.c environment_free_list.c \
|
free_token_list.c ft_lstclear_safe.c ft_lstnew_safe.c \
|
||||||
environment_update.c environment_add.c environment_print.c \
|
ft_strjoin_safe.c free_minishell_line.c ft_substr_safe.c \
|
||||||
environment_del.c environment_free.c environment_parse.c lexer_new.c \
|
ft_split_safe.c init_minishell.c print_banner.c ft_free_arr_safe.c \
|
||||||
lexer_read_word.c lexer_read_char.c lexer_parse_input.c \
|
error_msg.c free_command_list.c ft_strdup_safe.c malloc_safe.c \
|
||||||
lexer_parse_quotes.c lexer_token_next.c redirect_get_inputs.c \
|
free_minishell.c lexer_read_char.c lexer_new.c lexer_parse_quotes.c \
|
||||||
redirect_get_outputs.c redirect_new.c redirect_valid_type.c \
|
lexer_parse_input.c lexer_read_word.c lexer_token_next.c token_new.c \
|
||||||
redirect_new_error.c redirect_process_heredoc.c print_freelist.c \
|
token_char_convert.c token_parse.c token_type_convert.c \
|
||||||
print_commands.c main.c token_new.c token_char_convert.c \
|
environment_del.c environment_free.c environment_get.c \
|
||||||
token_parse.c token_type_convert.c signal_init.c.c signal.c \
|
environment_free_list.c environment_parse.c environment_add.c \
|
||||||
history_write.c prompt.c history_load.c free_command_list.c \
|
environment_get_arr.c environment_print.c environment_update.c \
|
||||||
free_minishell.c ft_lstnew_safe.c free_safe.c free_lexer.c \
|
executor_close_fds.c executor_open_fds.c executor_count_fds.c \
|
||||||
ft_free_arr_safe.c print_banner.c check_malloc.c free_freelist.c \
|
executor_create_pipes.c executor_create_redirects.c executor_fork.c \
|
||||||
ft_lstclear_safe.c ft_split_safe.c error_msg.c free_token_list.c \
|
executor_execute_pipeline.c executor_absolute_path.c executor_child.c \
|
||||||
malloc_safe.c free_minishell_line.c ft_strdup_safe.c free_token.c \
|
parser_create_command.c parser_validate_command.c \
|
||||||
ft_substr_safe.c init_minishell.c ft_strjoin_safe.c \
|
parser_alloc_command.c parser_get_commands.c parser_get_arguments.c \
|
||||||
expander_allocate_memory.c expander_parse_string.c \
|
parser_sanitize_string.c signal.c signal_init.c.c print_freelist.c \
|
||||||
expander_parse_variables.c expander_expand_dollar.c \
|
print_commands.c expander_expand_dollar.c expander_is_character.c \
|
||||||
expander_is_character.c expander_get_variable.c executor_open_fds.c \
|
expander_parse_variables.c expander_get_variable.c \
|
||||||
executor_count_fds.c executor_fork.c executor_absolute_path.c \
|
expander_allocate_memory.c expander_parse_string.c builtin_unset.c \
|
||||||
executor_execute_pipeline.c executor_child.c executor_close_fds.c \
|
builtin_pwd.c builtin_cd.c builtin_echo.c builtin_env.c \
|
||||||
executor_create_redirects.c executor_create_pipes.c builtin_export.c \
|
builtin_exit.c builtin_export.c builtin_router.c is_builtin.c \
|
||||||
simple_builtins.c builtin_router.c is_builtin.c builtin_unset.c \
|
simple_builtins.c redirect_process_heredoc.c redirect_get_inputs.c \
|
||||||
builtin_env.c builtin_cd.c builtin_pwd.c builtin_exit.c \
|
redirect_get_outputs.c redirect_new.c redirect_new_error.c \
|
||||||
builtin_echo.c \
|
redirect_valid_type.c main.c \
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: marvin <marvin@student.42.fr> +#+ */
|
/* By: marvin <marvin@student.42.fr> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/02/18 20:06:37 by qmennen #+# #+# */
|
/* 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)
|
if (!DEBUG)
|
||||||
return ;
|
return ;
|
||||||
token = (t_token *)param;
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: willem <willem@student.codam.nl> +#+ */
|
/* By: willem <willem@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/02/12 21:25:02 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);
|
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)
|
int executor_execute_pipeline(t_minishell *msh)
|
||||||
{
|
{
|
||||||
t_list *current;
|
t_list *current;
|
||||||
@ -47,11 +55,7 @@ int executor_execute_pipeline(t_minishell *msh)
|
|||||||
last_pid = 0;
|
last_pid = 0;
|
||||||
while (current)
|
while (current)
|
||||||
{
|
{
|
||||||
if (is_builtin(((t_command *)current->content)->args[0]) >= 0)
|
executor_execute_command(msh, (t_command *)current->content);
|
||||||
msh->exit_status = execute_builtin(msh,
|
|
||||||
(t_command *)current->content);
|
|
||||||
else
|
|
||||||
last_pid = executor_fork(msh, (t_command *)current->content);
|
|
||||||
current = current->next;
|
current = current->next;
|
||||||
}
|
}
|
||||||
if (last_pid != 0)
|
if (last_pid != 0)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user