42_minishell/heredoc.c
Camille Chauvet 67fb6d0533 -m
2023-02-14 07:26:18 +01:00

26 lines
369 B
C

#include "minishell.h"
#include <readline/history.h>
int ft_heredoc(char *stop)
{
int fds[2];
char *line;
pipe(fds);
line = readline("> ");
while (line != NULL)
{
if (ft_strcmp(line, stop) == 0)
{
free(line);
break ;
}
ft_putstr_fd(line, fds[1]);
add_history(line);
free(line);
line = readline("> ");
}
close(fds[1]);
return (fds[0]);
}