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.
/* By: ljiriste <ljiriste@student.42prague.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */
int stdin_fd;
int stdout_fd;
int ret_val;
- int may_exit;
int exit;
int last_was_builtin;
int last_builtin_ret_val;
/* By: ljiriste <ljiriste@student.42prague.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */
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)
/* By: lnikolov <lnikolov@student.42prague.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/21 08:57:54 by ljiriste #+# #+# */
-/* Updated: 2024/08/27 16:32:09 by ljiriste ### ########.fr */
+/* Updated: 2024/08/27 16:59:59 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
if (pipeline->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
{