From 6f3b1ab9185474d96043d7bb494b18fb1e7e2456 Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Thu, 30 Mar 2023 14:30:13 +0200 Subject: [PATCH 1/3] fix: execve failed --- execution/execution.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/execution/execution.c b/execution/execution.c index 7d0e81d..ac9baa0 100644 --- a/execution/execution.c +++ b/execution/execution.c @@ -6,7 +6,7 @@ /* By: cchauvet fd_in); ft_closer(cmd->fd_out); execve(cmd->executable, cmd->args, env); - ft_eprintf("minishell: permission denied: %s\n", cmd->executable); return (1); } return (0); From 41bbe2bc0b7da19f8ae49be9600dd189dbc97455 Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Thu, 30 Mar 2023 15:43:57 +0200 Subject: [PATCH 2/3] fix: quote closed verif --- syntax/syntax.c | 4 ++-- utils/ft_is_in_quote.c | 43 +++++++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/syntax/syntax.c b/syntax/syntax.c index c158681..0de5fc6 100644 --- a/syntax/syntax.c +++ b/syntax/syntax.c @@ -6,7 +6,7 @@ /* By: cchauvet int ft_is_in_quote(const char *str, size_t n) { - ssize_t i; + size_t i; + ssize_t start; - i = -1; - while (str[++i] != '\0' && i < (ssize_t) n) + start = -1; + i = 0; + while (str[i] != '\0') { - if (str[i] == '\'') + if (i == n) + break ; + if (str[i] == '\"' || str[i] == '\'') { - i++; - while (str[i] != '\'' && str[i] != '\0') - { - if (i == (ssize_t) n) - return (1); - i++; - } - } - if (str[i] == '"') - { - while (str[++i] != '"' && str[i] != '\0') - if (i == (ssize_t) n) - return (2); + if (start == -1) + start = i; + else if (str[i] == str[start]) + start = -1; } + i++; } - return (0); + if (start == -1) + return ((str[i] == '\'') + (str[i] == '\"') * 2); + if (str[start] == '\'') + return (1); + return (2); } From f66ab7790eee38e65fb83a5f47699ed38f6e62bf Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Thu, 30 Mar 2023 16:06:34 +0200 Subject: [PATCH 3/3] fix: 'echo '> >> < * ? [ ] | ; [ ] || && ( ) & # $ <<'' stop segfault now --- format/format.c | 4 ++-- syntax/syntax.c | 4 ++-- utils/ft_is_in_quote.c | 4 ++-- utils/utils.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/format/format.c b/format/format.c index eb025e2..490e1b3 100644 --- a/format/format.c +++ b/format/format.c @@ -6,7 +6,7 @@ /* By: cchauvet