From 46fe9caded50659245fc4302612cd9081e90a25a Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Fri, 31 Mar 2023 15:23:10 +0200 Subject: [PATCH] fix: heredoc work now --- redirection/heredoc.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/redirection/heredoc.c b/redirection/heredoc.c index cd5d133..0de873e 100644 --- a/redirection/heredoc.c +++ b/redirection/heredoc.c @@ -6,7 +6,7 @@ /* By: cchauvet "); + line = get_next_line(*ft_get_heredoc()); + if (line == NULL) + return (1); line[ft_strlen(line) - 1] = '\0'; if (ft_strcmp(line, stop) == 0) { @@ -46,30 +51,20 @@ static int ft_heredoc2(t_data *data, char *stop, char *line, int fds[2]) return (1); } free(line); - ft_printf("> "); - line = get_next_line(*ft_get_heredoc()); - if (line == NULL && *ft_get_heredoc() == -1) - { - ft_closer(fds); - return (1); - } return (0); } int ft_heredoc(t_data *data, char *stop) { - char *line; int fds[2]; int return_code; if (pipe(fds) == -1) return (-1); *ft_get_heredoc() = dup(0); - ft_printf("> "); - line = get_next_line(*ft_get_heredoc()); - while (line != NULL) + while (true) { - return_code = ft_heredoc2(data, stop, line, fds); + return_code = ft_heredoc2(data, stop, fds); if (return_code == 2) break ; else if (return_code)