diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/e_redirs.c | 10 | ||||
-rw-r--r-- | src/p_redirs.c | 3 | ||||
-rw-r--r-- | src/s_lredir.c | 10 |
3 files changed, 14 insertions, 9 deletions
diff --git a/src/e_redirs.c b/src/e_redirs.c index 246f2c7..1d66226 100644 --- a/src/e_redirs.c +++ b/src/e_redirs.c @@ -83,21 +83,15 @@ void e_dup_redirs(const t_com *com, t_msh *msh) while (ptr != NULL) { if (ptr->redir == -2 || ptr->redir == -3) - { e_redir_minus_two(ptr); - } else if (ptr->redir == -1) - { e_redir_minus_one(ptr, msh); - } else if (ptr->redir == 1) - { e_redir_plus_one(ptr, msh); - } else if (ptr->redir == 2) - { e_redir_plus_two(ptr, msh); - } + /* else if (ptr->redir == 3) */ + /* e_redir_plus_three(ptr, msh); */ ptr = ptr->next; } } diff --git a/src/p_redirs.c b/src/p_redirs.c index 6297255..108a2a3 100644 --- a/src/p_redirs.c +++ b/src/p_redirs.c @@ -44,6 +44,7 @@ static void p_append_redir(const char path[], new = s_lredir_new(path, fd, redir); if (new == NULL) { + /* TODO: return (1) and abort command right here */ return ; } new->heredoc = NULL; @@ -64,7 +65,7 @@ static size_t p_get_path(char path[], size_t len; hlen = 0; - tmp.ptr += ft_abs(tmp.redir); + tmp.ptr += (tmp.redir == 3) ? (2) : (ft_abs(tmp.redir)); while (*tmp.ptr != C_NUL && ft_iswhitespace(*tmp.ptr) == TRUE) tmp.ptr++; if (*tmp.ptr == C_TILDE && u_get_var_value(h, "$HOME", PATH_MAX, msh) == 0) diff --git a/src/s_lredir.c b/src/s_lredir.c index 0457434..109f313 100644 --- a/src/s_lredir.c +++ b/src/s_lredir.c @@ -64,6 +64,14 @@ void s_lredir_clear(struct s_lredir **lredir) *lredir = NULL; } +static int32_t s_get_right_fd(const char path[]) +{ + int32_t rfd; + + rfd = 0; + return (rfd); +} + struct s_lredir *s_lredir_new(const char path[], int32_t fd, int8_t redir) { struct s_lredir *rdr; @@ -72,6 +80,8 @@ struct s_lredir *s_lredir_new(const char path[], int32_t fd, int8_t redir) return (NULL); rdr->fd = fd; rdr->right_fd = -1; + if (redir == 3 && rdr->right_fd = s_get_right_fd(path) == -1) + return (NULL); rdr->redir = redir; rdr->next = NULL; ft_strlcpy(rdr->path, path, PATH_MAX); |