This commit is contained in:
Etienne Rey-bethbeder 2023-02-22 13:24:50 +01:00
commit cdde24f0d0
4 changed files with 16 additions and 14 deletions

Binary file not shown.

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/02/21 22:26:54 by cchauvet ### ########.fr */ /* Updated: 2023/02/21 23:34:37 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -108,7 +108,7 @@ static int ft_own_cmd(t_list **env, t_cmd *cmd)
else if (ft_strcmp(cmd->executable, "export") == 0) else if (ft_strcmp(cmd->executable, "export") == 0)
return_code = (print_export(env, cmd->fd_out)); return_code = (print_export(env, cmd->fd_out));
else if (ft_strcmp(cmd->executable, "cd") == 0) else if (ft_strcmp(cmd->executable, "cd") == 0)
return_code = (move_folder(cmd->args[0], cmd->fd_out)); return_code = (move_folder(cmd->args[1], cmd->fd_out));
/* if (ft_strcmp(cmd->executable, "unset") == 0) */ /* if (ft_strcmp(cmd->executable, "unset") == 0) */
/* return_code = (unset(env, cmd->args, cmd->fd_out)); */ /* return_code = (unset(env, cmd->args, cmd->fd_out)); */
else if (ft_strcmp(cmd->executable, "echo") == 0) else if (ft_strcmp(cmd->executable, "echo") == 0)

18
main.c
View File

@ -6,11 +6,10 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/16 15:16:14 by cchauvet #+# #+# */ /* Created: 2023/02/16 15:16:14 by cchauvet #+# #+# */
/* Updated: 2023/02/21 22:05:04 by cchauvet ### ########.fr */ /* Updated: 2023/02/21 23:54:44 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "libftx/libftx.h"
#include "minishell.h" #include "minishell.h"
static char *ft_get_user_input(t_list **env) static char *ft_get_user_input(t_list **env)
@ -43,14 +42,11 @@ static int ft_minishell(t_data *data, char *line)
int infile; int infile;
int outfile; int outfile;
if (ft_syntatic_verif(line))
return (1);
line_clean = ft_normalizer(line); line_clean = ft_normalizer(line);
if (line_clean == NULL) if (line_clean == NULL)
return (1); return (1);
if (ft_syntatic_verif(line_clean))
{
free(line_clean);
return (1);
}
outfile = ft_outfile(line_clean); outfile = ft_outfile(line_clean);
if (outfile == -2) if (outfile == -2)
{ {
@ -105,11 +101,19 @@ int main(int ac, char **av, char **env)
#else #else
void ft_ctrlc(int num)
{
rl_on_new_line();
ft_putchar_fd('\n', 1);
rl_redisplay();
}
int main(int ac, char **av, char **env) int main(int ac, char **av, char **env)
{ {
t_data data; t_data data;
char *line; char *line;
signal(SIGINT, ft_ctrlc);
data.env = init_env(env); data.env = init_env(env);
if (data.env == NULL) if (data.env == NULL)
return (1); return (1);

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/02/21 13:00:06 by cchauvet ### ########.fr */ /* Updated: 2023/02/21 23:40:20 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -18,7 +18,7 @@ static int ft_quote_verif(const char *str)
{ {
if (ft_is_in_quote(str, ft_strlen(str))) if (ft_is_in_quote(str, ft_strlen(str)))
{ {
ft_eprintf("minishell: Quote is note closed"); ft_eprintf("minishell: Quote is not closed\n");
return (1); return (1);
} }
else else
@ -78,7 +78,7 @@ static int ft_special_char_dub(const char *str)
if ((y > 2 && (str[i] == '>' || str[i] == '<')) if ((y > 2 && (str[i] == '>' || str[i] == '<'))
|| (y > 1 && str[i] == '|')) || (y > 1 && str[i] == '|'))
{ {
ft_eprintf("minishell: to many %c in a row", str, str[i]); ft_eprintf("minishell: too many %c in a row\n", str, str[i]);
return (1); return (1);
} }
i = i + y; i = i + y;
@ -96,8 +96,6 @@ int ft_empty_verif(const char *str)
i = 0; i = 0;
while (str[i] == ' ') while (str[i] == ' ')
i++; i++;
if (str[i] == '\0')
ft_eprintf("minishell: %s: command not found \n", str);
return (str[i] == '\0'); return (str[i] == '\0');
} }