|
@@ -7,7 +7,7 @@
|
|
|
** if > or >>: dup STDERR or STDOUT in to STDIN
|
|
|
*/
|
|
|
|
|
|
-void open_redirections(t_e *e, t_pipe *p, t_pipe_redir *t)
|
|
|
+void open_left_redirections(t_e *e, t_pipe *p, t_pipe_redir *t)
|
|
|
{
|
|
|
if (t->operator[0] == '|')
|
|
|
return ;
|
|
@@ -22,23 +22,6 @@ void open_redirections(t_e *e, t_pipe *p, t_pipe_redir *t)
|
|
|
prompt_redirection(e, p, t);
|
|
|
}
|
|
|
|
|
|
-/*
|
|
|
-** if != <<: close fd, restore stdfd
|
|
|
-*/
|
|
|
-
|
|
|
-void close_redirections(t_e *e, t_pipe *p, t_pipe_redir *t)
|
|
|
-{
|
|
|
- if (ft_strcmp(t->operator, "<<") != 0 && t->operator[0] != '|')
|
|
|
- {
|
|
|
- close(p->fd[p->i][0]);
|
|
|
- if (ft_strcmp(t->operator, "<") != 0)
|
|
|
- t->ifd == '2' ? close(STDERR) : close(STDOUT);
|
|
|
- else
|
|
|
- close(0);
|
|
|
- dup(p->fd[p->i][1]);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
/*
|
|
|
** for file writting: open, append or trunc
|
|
|
** for fd redirecting: ofd: output fd: dup ofd
|
|
@@ -46,7 +29,7 @@ void close_redirections(t_e *e, t_pipe *p, t_pipe_redir *t)
|
|
|
** save stdfd, dup new fd in STDIN
|
|
|
*/
|
|
|
|
|
|
-void right_redirections(t_e *e, t_pipe *p, t_pipe_redir *t)
|
|
|
+void open_right_redirections(t_e *e, t_pipe *p, t_pipe_redir *t)
|
|
|
{
|
|
|
int fd_file;
|
|
|
|
|
@@ -66,3 +49,20 @@ void right_redirections(t_e *e, t_pipe *p, t_pipe_redir *t)
|
|
|
dup2(t->ifd, t->ofd);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+/*
|
|
|
+** if != <<: close fd, restore stdfd
|
|
|
+*/
|
|
|
+
|
|
|
+void close_redirections(t_e *e, t_pipe *p, t_pipe_redir *t)
|
|
|
+{
|
|
|
+ if (ft_strcmp(t->operator, "<<") != 0 && t->operator[0] != '|')
|
|
|
+ {
|
|
|
+ close(p->fd[p->i][0]);
|
|
|
+ if (ft_strcmp(t->operator, "<") != 0)
|
|
|
+ t->ifd == '2' ? close(STDERR) : close(STDOUT);
|
|
|
+ else
|
|
|
+ close(0);
|
|
|
+ dup(p->fd[p->i][1]);
|
|
|
+ }
|
|
|
+}
|