|
@ -12,18 +12,22 @@ |
|
|
|
|
|
|
|
|
#include "minishell.h" |
|
|
#include "minishell.h" |
|
|
|
|
|
|
|
|
void push_heredoc(char *str, int fd) |
|
|
int push_heredoc(char *str) |
|
|
{ |
|
|
{ |
|
|
char *line; |
|
|
char *line; |
|
|
|
|
|
int pip[2]; |
|
|
|
|
|
|
|
|
while(1) |
|
|
pipe(pip); |
|
|
{ |
|
|
while(1) |
|
|
line = readline(">"); |
|
|
{ |
|
|
if (!ft_strncmp(line, str, ft_strlen(str) + 1)) |
|
|
line = readline(">"); |
|
|
break; |
|
|
if (!ft_strncmp(line, str, ft_strlen(str) + 1)) |
|
|
ft_putstr_fd(line, fd); |
|
|
break; |
|
|
write(fd, "\n", 1); |
|
|
ft_putstr_fd(line, pip[1]); |
|
|
} |
|
|
write(pip[1], "\n", 1); |
|
|
|
|
|
} |
|
|
|
|
|
close(pip[1]); |
|
|
|
|
|
return (pip[0]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
size_t count_arguments(t_token *tok) |
|
|
size_t count_arguments(t_token *tok) |
|
@ -64,8 +68,7 @@ void update_redir(t_command *cmd, t_token *tok) |
|
|
{ |
|
|
{ |
|
|
if (cmd->fd[0]) |
|
|
if (cmd->fd[0]) |
|
|
close(cmd->fd[0]); |
|
|
close(cmd->fd[0]); |
|
|
cmd->fd[0] = 0; |
|
|
cmd->fd[0] = push_heredoc(tok->value); |
|
|
cmd->heredoc = tok->value; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|