summaryrefslogtreecommitdiffstats
path: root/src/p_redirs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/p_redirs.c')
-rw-r--r--src/p_redirs.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/p_redirs.c b/src/p_redirs.c
index 108a2a3..0ecdee7 100644
--- a/src/p_redirs.c
+++ b/src/p_redirs.c
@@ -30,7 +30,7 @@
#include "u_parse.h"
#include "u_vars.h"
-static void p_append_redir(const char path[],
+static uint8_t p_append_redir(const char path[],
int32_t fd_rdr[],
t_com *com,
t_msh *msh)
@@ -44,8 +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 ;
+ return (1);
}
new->heredoc = NULL;
if (redir == -2 || redir == -3)
@@ -53,6 +52,7 @@ static void p_append_redir(const char path[],
new->heredoc = p_get_heredoc(path, redir, msh);
}
s_lredir_add_back(&com->rdr, new);
+ return (0);
}
static size_t p_get_path(char path[],
@@ -108,7 +108,7 @@ static int32_t p_get_fd(const char word[], char *ptr)
return (ft_atoi(digit));
}
-static void p_get_redir(char word[], char *ptr, t_com *com, t_msh *msh)
+static uint8_t p_get_redir(char word[], char *ptr, t_com *com, t_msh *msh)
{
struct s_rdr_tmp tmp;
char path[PATH_MAX];
@@ -131,7 +131,7 @@ static void p_get_redir(char word[], char *ptr, t_com *com, t_msh *msh)
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, com, msh);
+ return (p_append_redir(path, fd_rdr, com, msh));
}
int8_t p_redirs(char word[], t_com **com, t_msh *msh)
@@ -149,7 +149,8 @@ int8_t p_redirs(char word[], t_com **com, t_msh *msh)
mode = u_meet_squote(word, ptr, mode);
else if (mode == Q_NONE && (*ptr == '<' || *ptr == '>') == 1)
{
- p_get_redir(word, ptr, *com, msh);
+ if (p_get_redir(word, ptr, *com, msh) != 0)
+ return (1);
ptr = word;
}
ptr++;