diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-26 18:39:36 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-26 18:39:36 +0200 |
commit | 8b0cb4d5817c8577e8009b6488cb623c183c2dc6 (patch) | |
tree | 154f5a8612c949f3ce70b6eb5fb7af60a08bc151 /src/p_redirs.c | |
parent | TODO file update (diff) | |
download | 42-minishell-8b0cb4d5817c8577e8009b6488cb623c183c2dc6.tar.gz 42-minishell-8b0cb4d5817c8577e8009b6488cb623c183c2dc6.tar.bz2 42-minishell-8b0cb4d5817c8577e8009b6488cb623c183c2dc6.tar.xz 42-minishell-8b0cb4d5817c8577e8009b6488cb623c183c2dc6.tar.zst 42-minishell-8b0cb4d5817c8577e8009b6488cb623c183c2dc6.zip |
Pretty damn fine
Diffstat (limited to '')
-rw-r--r-- | src/p_redirs.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/p_redirs.c b/src/p_redirs.c index 3f9e866..cf4cf1d 100644 --- a/src/p_redirs.c +++ b/src/p_redirs.c @@ -13,11 +13,13 @@ #include <libft.h> #include <stdint.h> #include <stddef.h> +#include <unistd.h> #include <limits.h> #include "d_define.h" #include "s_lredir.h" #include "s_struct.h" +#include "s_lredir.h" #include "u_utils.h" #include "u_parse.h" @@ -26,7 +28,15 @@ static void p_append_redir(const char path[], int8_t redir, t_com *com) { - struct s_lredir *rdr; + struct s_lredir *new; + + new = s_lredir_new(path, fd, redir); + if (new == NULL) + { + return ; + } + s_lredir_add_back(&com->rdr, new); + } static size_t p_get_path(char path[], @@ -88,12 +98,12 @@ static int8_t p_get_redir(char word[], char *ptr, t_com *com) pos[0] = 0; pos[1] = 0; - if ((fd = p_get_fd(word, ptr)) < 0) - fd = 0; + if ((fd = p_get_fd(word, ptr)) <= 0) + fd = STDOUT_FILENO; redir = (*ptr == '>') ? (1) : (-1); redir = (redir == 1 && *(ptr + 1) == '>') ? (2) : (redir); redir = (redir == -1 && *(ptr + 1) == '<') ? (-2) : (redir); - if (fd == 0) + if (fd == STDOUT_FILENO) pos[0] = (ptr - word); else pos[0] = (ptr - word) - ft_intlen(fd); |