diff options
Diffstat (limited to '')
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | src/ft_e_lcom.c | 20 |
2 files changed, 17 insertions, 6 deletions
@@ -125,4 +125,5 @@ flycheck_*.el minishell minishell_history *.core -vgcore*
\ No newline at end of file +vgcore* +qwe
\ No newline at end of file diff --git a/src/ft_e_lcom.c b/src/ft_e_lcom.c index 5bffe0a..dab8f95 100644 --- a/src/ft_e_lcom.c +++ b/src/ft_e_lcom.c @@ -39,7 +39,7 @@ uint8_t { /* TODO: norme */ t_lcom *ptr; - int32_t write_fd; + int32_t fd; int32_t status; uint8_t bu_id; pid_t pid; @@ -52,15 +52,25 @@ uint8_t { if ((pid = fork()) == 0) { + fd = 0; + ft_printf("%hhd\n", ptr->redir); if (ptr->redir == 1) { - if ((write_fd = open(ptr->rdrpath, O_CREAT | O_RDWR, 0644))) + if ((fd = open(ptr->rdrpath, O_CREAT | O_RDWR, 0644))) { - /* TODO: handle err */ + /* TODO: handle err with errno */ } - dup2(write_fd, STDOUT_FILENO); - close(write_fd); + /* TODO: erase file and write */ } + else if (ptr->redir == 2) + { + if ((fd = open(ptr->rdrpath, O_CREAT | O_RDWR | O_APPEND, 0644))) + { + /* TODO: handle err with errno */ + } + } + dup2(fd, STDOUT_FILENO); + close(fd); msh->ret = msh->bu_ptr[bu_id](ptr->args, msh); exit(msh->ret); } |