42_minishell/heredoc.c

26 lines
369 B
C
Raw Normal View History

2023-02-14 01:26:18 -05:00
#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]);
}