Compare commits

..

No commits in common. "41bbe2bc0b7da19f8ae49be9600dd189dbc97455" and "94f55af0be04db3285e7a546d36f0fcfe7b90c03" have entirely different histories.

3 changed files with 26 additions and 24 deletions

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/21 12:45:16 by cchauvet #+# #+# */ /* Created: 2023/02/21 12:45:16 by cchauvet #+# #+# */
/* Updated: 2023/03/30 14:03:07 by cchauvet ### ########.fr */ /* Updated: 2023/03/29 18:53:35 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -58,6 +58,7 @@ static bool ft_executor(t_cmd *cmd, char **env, int fd)
ft_closer(cmd->fd_in); ft_closer(cmd->fd_in);
ft_closer(cmd->fd_out); ft_closer(cmd->fd_out);
execve(cmd->executable, cmd->args, env); execve(cmd->executable, cmd->args, env);
ft_eprintf("minishell: permission denied: %s\n", cmd->executable);
return (1); return (1);
} }
return (0); return (0);

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/21 13:00:05 by cchauvet #+# #+# */ /* Created: 2023/02/21 13:00:05 by cchauvet #+# #+# */
/* Updated: 2023/03/30 15:42:13 by cchauvet ### ########.fr */ /* Updated: 2023/03/30 12:45:18 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -86,7 +86,7 @@ static int ft_empty_verif(const char *str)
size_t i; size_t i;
i = 0; i = 0;
while (str[i] == ' ' || str[i] == '\"' || str[i] == '\'') while (str[i] == ' ')
i++; i++;
return (str[i] == '\0'); return (str[i] == '\0');
} }

View File

@ -3,38 +3,39 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* ft_is_in_quote.c :+: :+: :+: */ /* ft_is_in_quote.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/30 15:39:25 by cchauvet #+# #+# */ /* Created: 2023/02/21 12:59:34 by cchauvet #+# #+# */
/* Updated: 2023/03/30 15:40:06 by cchauvet ### ########.fr */ /* Updated: 2023/03/27 15:32:44 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "utils.h" #include "utils.h"
#include <sys/types.h>
int ft_is_in_quote(const char *str, size_t n) int ft_is_in_quote(const char *str, size_t n)
{ {
size_t i; ssize_t i;
ssize_t start;
start = -1; i = -1;
i = 0; while (str[++i] != '\0' && i < (ssize_t) n)
while (str[i] != '\0')
{ {
if (i == n) if (str[i] == '\'')
break ;
if (str[i] == '\"' || str[i] == '\'')
{ {
if (start == -1) i++;
start = i; while (str[i] != '\'' && str[i] != '\0')
else if (str[i] == str[start]) {
start = -1; if (i == (ssize_t) n)
return (1);
i++;
}
}
if (str[i] == '"')
{
while (str[++i] != '"' && str[i] != '\0')
if (i == (ssize_t) n)
return (2);
} }
i++;
} }
if (start == -1) return (0);
return ((str[i] == '\'') + (str[i] == '\"') * 2);
if (str[start] == '\'')
return (1);
return (2);
} }