From: Lukáš Jiřiště Date: Tue, 27 Aug 2024 15:02:44 +0000 (+0200) Subject: Remove may_exit member of env X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=a60f3d509f46465d54da4f2717b09b18a598d9e7;p=42%2Fminishell.git Remove may_exit member of env This was implemented to mimic the behaviour of piped exit. But bash just runs piped commands in separate processes which leads to piped builtins not having effect on the current session. So I think it will be more pure without this check and if the bash behaviour is needed, piping may be delegated to forked processes. --- diff --git a/inc/minishell_structs.h b/inc/minishell_structs.h index 20b2085..5c9f5ba 100644 --- a/inc/minishell_structs.h +++ b/inc/minishell_structs.h @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/26 09:08:46 by ljiriste #+# #+# */ -/* Updated: 2024/08/27 15:03:52 by ljiriste ### ########.fr */ +/* Updated: 2024/08/27 16:59:59 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,7 +31,6 @@ typedef struct s_execution_env int stdin_fd; int stdout_fd; int ret_val; - int may_exit; int exit; int last_was_builtin; int last_builtin_ret_val; diff --git a/src/builtins/exit.c b/src/builtins/exit.c index 7a978a2..149397b 100644 --- a/src/builtins/exit.c +++ b/src/builtins/exit.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/27 14:49:17 by ljiriste #+# #+# */ -/* Updated: 2024/08/27 15:05:25 by ljiriste ### ########.fr */ +/* Updated: 2024/08/27 17:00:31 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,8 +32,7 @@ int is_numeric(const char *str) int execute_exit(int argc, char **argv, t_execution_env *env) { - if (env->may_exit) - env->exit = 1; + env->exit = 1; if (argc == 1) return (0); if (argc > 2) diff --git a/src/execution.c b/src/execution.c index b8db20e..9a07f82 100644 --- a/src/execution.c +++ b/src/execution.c @@ -6,7 +6,7 @@ /* By: lnikolov children.size == 1) { - env->may_exit = (depth == 0); if (ex_command(ft_vec_access(&pipeline->children, 0), env)) return (1); - env->may_exit = 0; } else {