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); 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 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 (0); + if (str[start] == '\'') + return (1); + return (2); } diff --git a/utils/utils.h b/utils/utils.h index 871e07f..d733ea2 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -6,7 +6,7 @@ /* By: cchauvet