diff options
Diffstat (limited to '')
-rw-r--r-- | src/e_redirs.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/e_redirs.c b/src/e_redirs.c index 7416349..b07026f 100644 --- a/src/e_redirs.c +++ b/src/e_redirs.c @@ -15,12 +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) +{ + (void)msh; + if (ptr->heredoc == NULL) + { + return ; + } + dup2(STDOUT_FILENO, STDIN_FILENO); + write(STDOUT_FILENO, ptr->heredoc, ft_strlen(ptr->heredoc) + 1); + close(STDIN_FILENO); +} + static void e_redir_minus_one(struct s_lredir *ptr, t_msh *msh) { int32_t fd; @@ -67,7 +80,11 @@ void e_dup_redirs(const t_com *com, t_msh *msh) ptr = com->rdr; while (ptr != NULL) { - if (ptr->redir == -1) + if (ptr->redir == -2) + { + e_redir_minus_two(ptr, msh); + } + else if (ptr->redir == -1) { e_redir_minus_one(ptr, msh); } |