summaryrefslogtreecommitdiffstats
path: root/src/ft_e_builtins.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_e_builtins.c')
-rw-r--r--src/ft_e_builtins.c24
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);
}
}