diff options
Diffstat (limited to 'src/ft_e_builtins.c')
-rw-r--r-- | src/ft_e_builtins.c | 17 |
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 |