From cbbe5e77159719bea34505998c4776311df47281 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Mon, 28 Sep 2020 18:26:19 +0200 Subject: oh yes --- src/e_redirs.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/e_redirs.c') 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 #include #include -#include #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) { -- cgit v1.2.3