Browse Source

[mod] move 'open_left_redirections()' inside multipiping.

Moul 2 years ago
parent
commit
e568218aaa
1 changed files with 3 additions and 6 deletions
  1. 3 6
      src/pipe_exec.c

+ 3 - 6
src/pipe_exec.c

@@ -17,11 +17,7 @@ void	launch_pipes(t_e *e, t_pipe *p, t_pipe_redir **t)
 			p->cmd_opt[p->i] = cmd_splitting(e, t[p->i]->itxt, ' ');
 			remove_cotes(p->cmd_opt[p->i]);
 		}
-		open_left_redirections(e, p, t[p->i]);
-		if (ft_strcmp(t[p->i]->operator, "<<") != 0)
-			handle_multi_piping(e, p, t[p->i]);
-		if (ft_strstr(t[p->i]->operator, ">") == NULL)
-			close_redirections(e, p, t[p->i]);
+		handle_multi_piping(e, p, t[p->i]);
 		free(p->cmd_opt[p->i]);
 		if (p->i != 0)
 			free(p->fd[p->i - 1]);
@@ -55,6 +51,7 @@ void	handle_multi_piping(t_e *e, t_pipe *p, t_pipe_redir *t)
 		ok = manage_cmd_1(e, p->cmd_opt[p->i]);
 	if (fork() == 0)
 	{
+		open_left_redirections(e, p, t);
 		if (p->i < p->nbr)
 		{
 			close(p->fd[p->i][0]);
@@ -80,7 +77,7 @@ void	inside_pipe(t_e *e, t_pipe *p, t_pipe_redir *t)
 {
 	if (ft_strstr(t->operator, ">") != NULL)
 		open_right_redirections(e, p, t);
-	if (t->itxt != NULL)
+	if (t->itxt != NULL && ft_strcmp(t->operator, "<<") != 0)
 		manage_cmd_2(e, p->cmd_opt[p->i]);
 	if (ft_strstr(t->operator, ">") != NULL)
 		close_redirections(e, p, t);