summaryrefslogtreecommitdiffstats
path: root/src/p_redirs.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-09-27 20:59:02 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-09-27 20:59:02 +0200
commitcc3aa4907949a66187d0a91b1f7cb55b5cdb21b3 (patch)
tree5f4712c4aa495d97ed1c64b1f828f48febba9c31 /src/p_redirs.c
parentProgress (diff)
download42-minishell-cc3aa4907949a66187d0a91b1f7cb55b5cdb21b3.tar.gz
42-minishell-cc3aa4907949a66187d0a91b1f7cb55b5cdb21b3.tar.bz2
42-minishell-cc3aa4907949a66187d0a91b1f7cb55b5cdb21b3.tar.xz
42-minishell-cc3aa4907949a66187d0a91b1f7cb55b5cdb21b3.tar.zst
42-minishell-cc3aa4907949a66187d0a91b1f7cb55b5cdb21b3.zip
In progress
Diffstat (limited to 'src/p_redirs.c')
-rw-r--r--src/p_redirs.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/p_redirs.c b/src/p_redirs.c
index 7c71d13..b615d01 100644
--- a/src/p_redirs.c
+++ b/src/p_redirs.c
@@ -18,6 +18,7 @@
#include "d_define.h"
#include "p_redirs.h"
+#include "p_redirs_heredoc.h"
#include "s_lredir.h"
#include "s_struct.h"
#include "s_lredir.h"
@@ -31,15 +32,22 @@ static void p_append_redir(const char path[],
t_msh *msh)
{
struct s_lredir *new;
+ int32_t fd;
+ int8_t redir;
+ fd = fd_rdr[FD];
+ redir = fd_rdr[RDR];
new = s_lredir_new(path, fd, redir);
if (new == NULL)
{
return ;
}
- s_lredir_add_back(&com->rdr, new);
+ new->heredoc = NULL;
if (redir == -2)
- p_get_heredoc(path, msh->fd);
+ {
+ new->heredoc = p_get_heredoc(path, msh);
+ }
+ s_lredir_add_back(&com->rdr, new);
}
static size_t p_get_path(char path[],
@@ -112,14 +120,14 @@ static void p_get_redir(char word[], char *ptr, t_com *com, t_msh *msh)
if (fd_rdr[FD] == STDOUT_FILENO)
pos[0] = (ptr - word);
else
- pos[0] = (ptr - word) - ft_intlen(fd);
+ pos[0] = (ptr - word) - ft_intlen(fd_rdr[FD]);
tmp.word = word;
tmp.ptr = ptr;
- tmp.redir = redir;
+ tmp.redir = fd_rdr[RDR];
pos[1] = p_get_path(path, tmp, msh);
(void)ft_memmove(word + pos[0],
word + pos[1], (ft_strlen(word + pos[1]) + 1) * sizeof(char));
- p_append_redir(path, fd_rdr, redir, com);
+ p_append_redir(path, fd_rdr, com, msh);
}
int8_t p_redirs(char word[], t_com **com, t_msh *msh)