This commit is contained in:
Camille Chauvet 2023-02-17 19:05:33 +01:00
parent 4b5a50d7fe
commit c75c6838d6
5 changed files with 15 additions and 24 deletions

Binary file not shown.

23
main.c
View File

@ -6,7 +6,7 @@
/* 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/17 18:22:52 by cchauvet ### ########.fr */ /* Updated: 2023/02/17 18:59:50 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -33,6 +33,7 @@ static char *ft_get_user_input(t_list **env)
static int ft_minishell(t_list **env, char *line) static int ft_minishell(t_list **env, char *line)
{ {
t_list **cmds; t_list **cmds;
int code;
char *line_clean; char *line_clean;
int infile; int infile;
int outfile; int outfile;
@ -68,16 +69,11 @@ static int ft_minishell(t_list **env, char *line)
free(line_clean); free(line_clean);
return (1); return (1);
} }
if (ft_cmds_executor(cmds, env) == 1) code = ft_cmds_executor(cmds, env);
{ ft_lstclear(cmds, ft_cmddel);
close(outfile); free(cmds);
close(infile); free(line_clean);
ft_lstclear(cmds, ft_cmddel); return (code);
free(cmds);
free(line_clean);
return (1);
}
return (0);
} }
#if DEBUG #if DEBUG
@ -104,8 +100,6 @@ int main(int ac, char **av, char **env)
#else #else
int main(int ac, char **av, char **env) int main(int ac, char **av, char **env)
{ {
t_data data; t_data data;
@ -123,7 +117,8 @@ int main(int ac, char **av, char **env)
} }
while (line != NULL) while (line != NULL)
{ {
ft_minishell(data.env, line); if (ft_minishell(data.env, line) == 2)
break ;
free(line); free(line);
line = ft_get_user_input(data.env); line = ft_get_user_input(data.env);
if (line == NULL) if (line == NULL)

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/14 13:45:30 by cchauvet #+# #+# */ /* Created: 2023/02/14 13:45:30 by cchauvet #+# #+# */
/* Updated: 2023/02/17 18:24:08 by cchauvet ### ########.fr */ /* Updated: 2023/02/17 18:51:58 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -21,7 +21,7 @@
# include <stdio.h> # include <stdio.h>
# include <readline/readline.h> # include <readline/readline.h>
# include <readline/history.h> # include <readline/history.h>
# define DEBUG 1 # define DEBUG 0
int ft_syntatic_verif(const char *str); int ft_syntatic_verif(const char *str);
int ft_file_is_readable(const char *path); int ft_file_is_readable(const char *path);

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/15 18:01:07 by cchauvet #+# #+# */ /* Created: 2023/02/15 18:01:07 by cchauvet #+# #+# */
/* Updated: 2023/02/17 18:50:02 by cchauvet ### ########.fr */ /* Updated: 2023/02/17 19:03:00 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -86,14 +86,11 @@ static int ft_remove_outfile(char *line)
{ {
if (tab[i][0] == '>') if (tab[i][0] == '>')
{ {
ft_strshift(line + y, -1 * (ft_strlen(tab[i]) + ft_strlen(tab[i + 1]) + 2)); ft_strshift(line + y,
-1 * (ft_strlen(tab[i]) + ft_strlen(tab[i + 1]) + 2));
} }
else else
{ y = y + ft_strlen(tab[i]) + (y != 0);
if (y != 0)
y++;
y = y + ft_strlen(tab[i]);
}
i++; i++;
} }
ft_freer_tab_ultimate(1, tab); ft_freer_tab_ultimate(1, tab);

1
t
View File

@ -1 +0,0 @@
bozo