summaryrefslogtreecommitdiffstats
path: root/src/ft_e_builtins.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-28 15:49:58 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-28 15:49:58 +0200
commit86b25977265727217ec3360c3dc19b74f2bd448f (patch)
treeeefc1440e2ae18faaab0e5409dac58bfef893813 /src/ft_e_builtins.c
parentNice functional cd (diff)
download42-minishell-86b25977265727217ec3360c3dc19b74f2bd448f.tar.gz
42-minishell-86b25977265727217ec3360c3dc19b74f2bd448f.tar.bz2
42-minishell-86b25977265727217ec3360c3dc19b74f2bd448f.tar.xz
42-minishell-86b25977265727217ec3360c3dc19b74f2bd448f.tar.zst
42-minishell-86b25977265727217ec3360c3dc19b74f2bd448f.zip
exit is fine
Diffstat (limited to 'src/ft_e_builtins.c')
-rw-r--r--src/ft_e_builtins.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/ft_e_builtins.c b/src/ft_e_builtins.c
index c78a80c..382f85d 100644
--- a/src/ft_e_builtins.c
+++ b/src/ft_e_builtins.c
@@ -42,17 +42,28 @@ static void
t_msh *msh)
{
int32_t status;
+ int32_t ret;
while (wait(&status) != pid)
;
- msh->ret = WEXITSTATUS(status);
+ ret = WEXITSTATUS(status);
+ if (bu_id != 6)
+ msh->ret = ret;
if (bu_id == 1 && msh->ret == 0)
{
msh->bu_ptr[bu_id](ptr->argv + 1, msh);
/* TODO: export $PWD */
}
- else if (bu_id == 6)
- msh->bu_ptr[bu_id](ptr->argv + 1, msh);
+ else if (bu_id == 6 && ret == 0)
+ {
+ if (ptr->argv[1])
+ ret = ft_atoi(ptr->argv[1]);
+ else
+ ret = msh->ret;
+ ft_lcom_clear(&msh->curr);
+ ft_s_destroy(msh);
+ exit(ret);
+ }
}
void