summaryrefslogtreecommitdiffstats
path: root/src/s_com.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/s_com.c')
-rw-r--r--src/s_com.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/s_com.c b/src/s_com.c
index 28b460f..6dd4dc0 100644
--- a/src/s_com.c
+++ b/src/s_com.c
@@ -19,6 +19,7 @@
#include "p_args.h"
#include "p_lblock.h"
#include "p_lblock_next.h"
+#include "s_lredir.h"
#include "s_struct.h"
static int8_t
@@ -38,20 +39,12 @@ static int8_t
}
else
return (0);
- while(words[i])
- {
- /* TODO: cut fd number "msh ~> echo a 2>file" */
- /* ^ */
- if (ft_ischarset("<>", words[i][0]) == TRUE)
- break ;
- i++;
- }
- if (!((*com)->argv = (char**)malloc((i + 1) * sizeof(char*))))
+ if (((*com)->argv = (char**)malloc((i + 1) * sizeof(char*))) == NULL)
return (-1);
j = 0;
while (i > 0 && j < i)
{
- if (!((*com)->argv[j] = ft_strdup(words[j])))
+ if (((*com)->argv[j] = ft_strdup(words[j])) == NULL)
return (-1);
j++;
}
@@ -93,6 +86,8 @@ void
ft_memdel((void*)&ptr->rdrpath);
if (ptr->env_fork != NULL)
ft_delwords(ptr->env_fork);
+ if (ptr->rdr != NULL)
+ s_lredir_clear(&ptr->rdr);
ft_memdel((void*)&ptr);
}
@@ -107,15 +102,13 @@ t_com
if ((com = (t_com*)malloc(sizeof(t_com))) == NULL)
return (NULL);
- com->redir = 0;
+ com->redir = NULL;
com->bin = NULL;
com->argv = NULL;
- com->rdrfd = 0;
- com->rdrpath = NULL;
com->env_fork = NULL;
nword[0] = C_NUL;
ft_strlcpy(nword, word, ARG_MAX);
- if (p_get_redir(nword, &com) != 0)
+ if (p_get_redirs(nword, &com) != 0)
return (NULL);
if (msh->alias != NULL)
{