summaryrefslogtreecommitdiffstats
path: root/src/p_args.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-09-06 21:56:20 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-09-06 21:56:20 +0200
commit4543c3ba3222d47780ad3e091cfe6f3098cc2bca (patch)
treefb8a70bf05464a6fa2c820cc43ea34421340c903 /src/p_args.c
parentCommit from minishell (diff)
download42-minishell-4543c3ba3222d47780ad3e091cfe6f3098cc2bca.tar.gz
42-minishell-4543c3ba3222d47780ad3e091cfe6f3098cc2bca.tar.bz2
42-minishell-4543c3ba3222d47780ad3e091cfe6f3098cc2bca.tar.xz
42-minishell-4543c3ba3222d47780ad3e091cfe6f3098cc2bca.tar.zst
42-minishell-4543c3ba3222d47780ad3e091cfe6f3098cc2bca.zip
Stacked
Diffstat (limited to 'src/p_args.c')
-rw-r--r--src/p_args.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/src/p_args.c b/src/p_args.c
index ae92523..b449ba3 100644
--- a/src/p_args.c
+++ b/src/p_args.c
@@ -20,27 +20,6 @@
#include "p_args_escape.h"
#include "u_utils.h"
-/* ================= */
-/* TODO: DELETE THIS */
-/* ================= */
-
-/* static void */
-/* p_print(char *words[]) */
-/* { */
-/* char **ptr; */
-
-/* ptr = words; */
-/* while (*ptr != NULL) */
-/* { */
-/* ft_printf("[%s]\n", *ptr); */
-/* ptr++; */
-/* } */
-/* } */
-
-/* ================== */
-/* TODO: DELETE ABOVE */
-/* ================== */
-
static void
p_meet_bs(char *ptr, t_quote_mode mode)
{
@@ -166,15 +145,14 @@ static char
return (NULL);
}
p_args_escape_chars_and_quotes(words);
- /* p_print(words); */
- /* exit(0); */
return (words);
}
char
- **p_split_args(const char word[], int8_t redir)
+ **p_split_args(char word[], int8_t redir)
{
char **words;
+ size_t i;
words = NULL;
if (redir == 0)
@@ -183,6 +161,16 @@ char
return (NULL);
return (words);
}
+ i = ft_strlen(word);
+ while (ft_ischarset("<>", word[i]) == FALSE)
+ i--;
+ i--;
+ while (redir > 0 && ft_isdigit(word[i]) == TRUE)
+ i--;
+ word[i] = C_NUL;
+ ft_printf("[%s]\n", word);
+ if ((words = p_split_words_no_rdr(word)) == NULL)
+ return (NULL);
return (words);
/* char **words; */
/* char *subst; */