diff options
author | salad <fmoenne-@student.le-101.fr> | 2020-04-29 11:47:02 +0200 |
---|---|---|
committer | salad <fmoenne-@student.le-101.fr> | 2020-04-29 11:47:02 +0200 |
commit | 961bda4f42562bf8ceb70a888730362d021c5552 (patch) | |
tree | 820577dc790c3a8884c44b329d04a8d42ed1ca44 /src/ft_e_builtins.c | |
parent | simple really (diff) | |
parent | Trying vars (diff) | |
download | 42-minishell-961bda4f42562bf8ceb70a888730362d021c5552.tar.gz 42-minishell-961bda4f42562bf8ceb70a888730362d021c5552.tar.bz2 42-minishell-961bda4f42562bf8ceb70a888730362d021c5552.tar.xz 42-minishell-961bda4f42562bf8ceb70a888730362d021c5552.tar.zst 42-minishell-961bda4f42562bf8ceb70a888730362d021c5552.zip |
merge master into fmoenne_indahouse
Diffstat (limited to '')
-rw-r--r-- | src/ft_e_builtins.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/ft_e_builtins.c b/src/ft_e_builtins.c index bc3eece..382f85d 100644 --- a/src/ft_e_builtins.c +++ b/src/ft_e_builtins.c @@ -37,13 +37,33 @@ static void static void ft_e_builtin_parent(pid_t pid, + const t_lcom *ptr, + uint8_t bu_id, 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 && 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 @@ -64,6 +84,6 @@ void } else { - ft_e_builtin_parent(pid, msh); + ft_e_builtin_parent(pid, ptr, bu_id, msh); } } |