diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-23 01:02:29 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-23 01:02:29 +0200 |
commit | fa1bce6a580d380ef779c688d6ec3f0d78c0c08b (patch) | |
tree | ee26b04623b5deeeb88d4304de7f39947257d1e4 /src/ft_e_lcom.c | |
parent | Now time to pipe(2) (diff) | |
download | 42-minishell-fa1bce6a580d380ef779c688d6ec3f0d78c0c08b.tar.gz 42-minishell-fa1bce6a580d380ef779c688d6ec3f0d78c0c08b.tar.bz2 42-minishell-fa1bce6a580d380ef779c688d6ec3f0d78c0c08b.tar.xz 42-minishell-fa1bce6a580d380ef779c688d6ec3f0d78c0c08b.tar.zst 42-minishell-fa1bce6a580d380ef779c688d6ec3f0d78c0c08b.zip |
nigga be eating my prompt
Diffstat (limited to '')
-rw-r--r-- | src/ft_e_lcom.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ft_e_lcom.c b/src/ft_e_lcom.c index e8787da..acfc187 100644 --- a/src/ft_e_lcom.c +++ b/src/ft_e_lcom.c @@ -13,6 +13,8 @@ #include <libft.h> #include <stdint.h> #include <stdlib.h> +#include <fcntl.h> +#include <unistd.h> #include "ft_s_struct.h" static uint8_t @@ -32,6 +34,7 @@ static uint8_t uint8_t ft_e_lcom(t_msh *msh) { + int fd; t_lcom *ptr; uint8_t bu_id; @@ -41,7 +44,13 @@ uint8_t if ((bu_id = ft_get_builtin_id(ptr->com, msh)) < FT_BUILTINS_COUNT) { + if (ptr->redir == 1 && + (fd = open(ptr->rdrpath, O_CREAT | O_WRONLY, 0644))) + { + dup2(fd, STDOUT_FILENO); + } msh->ret = msh->bu_ptr[bu_id](ptr->args, msh); + close(fd); } else { |