diff options
Diffstat (limited to 'src/e_redirs.c')
-rw-r--r-- | src/e_redirs.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/e_redirs.c b/src/e_redirs.c index b07026f..6bb600f 100644 --- a/src/e_redirs.c +++ b/src/e_redirs.c @@ -15,23 +15,25 @@ #include <stddef.h> #include <fcntl.h> #include <unistd.h> -#include <stdio.h> #include "f_fail.h" #include "s_destroy.h" #include "s_line.h" #include "s_struct.h" -static void e_redir_minus_two(struct s_lredir *ptr, t_msh *msh) +static void e_redir_minus_two(struct s_lredir *ptr) { - (void)msh; + int32_t fd[2]; + if (ptr->heredoc == NULL) { return ; } - dup2(STDOUT_FILENO, STDIN_FILENO); - write(STDOUT_FILENO, ptr->heredoc, ft_strlen(ptr->heredoc) + 1); - close(STDIN_FILENO); + pipe(fd); + dup2(fd[0], STDIN_FILENO); + ft_dprintf(fd[1], "%s", ptr->heredoc); + close(fd[1]); + close(fd[0]); } static void e_redir_minus_one(struct s_lredir *ptr, t_msh *msh) @@ -82,7 +84,7 @@ void e_dup_redirs(const t_com *com, t_msh *msh) { if (ptr->redir == -2) { - e_redir_minus_two(ptr, msh); + e_redir_minus_two(ptr); } else if (ptr->redir == -1) { |