diff options
Diffstat (limited to 'src/s_com.c')
-rw-r--r-- | src/s_com.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/s_com.c b/src/s_com.c index 6d6ee09..277d996 100644 --- a/src/s_com.c +++ b/src/s_com.c @@ -12,7 +12,9 @@ #include <libft.h> #include <stdlib.h> +#include <limits.h> +#include "d_define.h" #include "f_fail.h" #include "p_args.h" #include "p_lblock.h" @@ -98,6 +100,7 @@ void t_com *s_com_new(char word[], t_msh *msh) { + char nword[ARG_MAX]; t_com *com; char **words; @@ -109,12 +112,12 @@ t_com com->rdrfd = 0; com->rdrpath = NULL; com->env_fork = NULL; - if (p_get_redir(word, &com) != 0) + nword[0] = C_NUL; + ft_strlcpy(nword, word, ARG_MAX); + if (p_get_redir(nword, &com) != 0) return (NULL); - if ((word = p_subst_vars(word, msh)) == NULL) - return (NULL); - msh->curr->lblock = word; - if ((words = p_split_args(word, com->redir)) == NULL) + p_subst_vars(nword, msh); + if ((words = p_split_args(nword, com->redir)) == NULL) return (NULL); if ((words = p_subst_home(words, msh)) == NULL) return (NULL); |