diff --git a/src/errors/errors.c b/src/errors/errors.c index dea4162..c22a1af 100644 --- a/src/errors/errors.c +++ b/src/errors/errors.c @@ -6,7 +6,7 @@ /* By: sede-san static uint8_t resolve_execve_status(void) @@ -60,10 +61,7 @@ static void execute_external_command( envp = get_envp(minishell); if (envp == NULL) - { - perror("get_envp"); - exit(EXIT_FAILURE); - } + return (malloc_error(), exit(EXIT_FAILURE)); execve(command->path, command->argv, envp); handle_execve_error(command, envp); } @@ -81,10 +79,7 @@ uint8_t executor_execute_command( free(command->path); command->path = executor_resolve_command_path(command, minishell); if (command->path == NULL) - { - ft_eprintf("minishell: %s: command not found\n", command->argv[0]); - return (127); - } + return (command_not_found_error(command->argv[0]), 127); execute_external_command(command, minishell); return (EXIT_FAILURE); } diff --git a/src/executor/executor.c b/src/executor/executor.c index c93d325..375e5a2 100644 --- a/src/executor/executor.c +++ b/src/executor/executor.c @@ -6,7 +6,7 @@ /* By: sede-san exit = true; return (true); } diff --git a/src/variables/environment/environment.c b/src/variables/environment/environment.c index 095f9fc..7482adf 100644 --- a/src/variables/environment/environment.c +++ b/src/variables/environment/environment.c @@ -6,7 +6,7 @@ /* By: sede-san variables.environment; - key = (char *)name; - if (key != NULL && !ft_hashmap_contains_key(environment, key)) + if (name != NULL && !ft_hashmap_contains_key(environment, name)) { key = ft_strdup(name); if (key == NULL) - { - minishell->exit = true; - malloc_error(); - return ; - } + return (minishell->exit = true, malloc_error()); } - val = value; - if (val == NULL) + if (value == NULL) val = ft_strdup(""); else val = ft_strdup(value); @@ -79,9 +73,7 @@ void set_env( { if (key != name) free(key); - minishell->exit = true; - malloc_error(); - return ; + return (minishell->exit = true, malloc_error()); } old_value = ft_hashmap_put(environment, key, val); if (old_value != NULL)