summaryrefslogtreecommitdiffstats
path: root/src/ft_s_lcom.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-22 23:56:52 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-22 23:56:52 +0200
commit04e558ff314dfe8bdac7ea1139e9caf9b063f855 (patch)
treeb4c06d52569d568a50bfce9be5d2f4738cb82671 /src/ft_s_lcom.c
parentGathering rdrpath successfully (diff)
download42-minishell-04e558ff314dfe8bdac7ea1139e9caf9b063f855.tar.gz
42-minishell-04e558ff314dfe8bdac7ea1139e9caf9b063f855.tar.bz2
42-minishell-04e558ff314dfe8bdac7ea1139e9caf9b063f855.tar.xz
42-minishell-04e558ff314dfe8bdac7ea1139e9caf9b063f855.tar.zst
42-minishell-04e558ff314dfe8bdac7ea1139e9caf9b063f855.zip
Good
Diffstat (limited to 'src/ft_s_lcom.c')
-rw-r--r--src/ft_s_lcom.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/ft_s_lcom.c b/src/ft_s_lcom.c
index f469edb..b31f5e5 100644
--- a/src/ft_s_lcom.c
+++ b/src/ft_s_lcom.c
@@ -29,21 +29,22 @@ static int8_t
return (-1);
ft_strlcpy((*lcom)->com, words[0], ft_strlen(words[0]) + 1);
while(words[i + 1])
+ {
+ if (ft_ischarset("<>", words[i + 1][0]))
+ break ;
i++;
+ }
if (!((*lcom)->args = (char**)malloc((i + 1) * sizeof(char*))))
return (-1);
j = 0;
- if (i > 0)
+ while (i > 0 && j < i)
{
- while (j < i)
- {
- if (!((*lcom)->args[j] =
- (char*)malloc((ft_strlen(words[j + 1]) + 1) * sizeof(char))))
- return (-1);
- ft_strlcpy((*lcom)->args[j], words[j + 1],
- ft_strlen(words[j + 1]) + 1);
- j++;
- }
+ if (!((*lcom)->args[j] =
+ (char*)malloc((ft_strlen(words[j + 1]) + 1) * sizeof(char))))
+ return (-1);
+ ft_strlcpy((*lcom)->args[j], words[j + 1],
+ ft_strlen(words[j + 1]) + 1);
+ j++;
}
(*lcom)->args[j] = 0;
return (0);
@@ -107,7 +108,6 @@ t_lcom
link->com = NULL;
link->args = NULL;
link->rdrpath = NULL;
- /* TODO: redirections here */
if (ft_get_redir(word, &link) != 0)
return (NULL);
if (!(words = ft_split(word, ' ')))