37 lines
1.2 KiB
C
37 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* heredoc.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/02/17 15:36:26 by cchauvet #+# #+# */
|
|
/* Updated: 2023/02/17 16:21:02 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libftx/libftx.h"
|
|
#include "minishell.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_putendl_fd(line, fds[1]);
|
|
free(line);
|
|
line = readline("> ");
|
|
}
|
|
close(fds[1]);
|
|
return (fds[0]);
|
|
}
|