diff --git a/srcs/main.c b/srcs/main.c index e46ae2e..c40df95 100644 --- a/srcs/main.c +++ b/srcs/main.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/04 05:59:26 by lperrey #+# #+# */ -/* Updated: 2021/10/19 21:16:21 by hulamy ### ########.fr */ +/* Updated: 2021/10/19 21:27:19 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -205,7 +205,7 @@ int handle_fd(char **input, int i, int fdin, int *fd_in, int *fd_out) } //t_list *parser(char *input) -void parser(char *input, char **envp) +t_list *parser(char *input, char **envp) { t_list *cmd; t_cmd *element; @@ -216,21 +216,25 @@ void parser(char *input, char **envp) input_split = ft_split(input, '|'); tmp_fd = 0; i = 0; + cmd = NULL; while (input_split[i]) { element = calloc(1, sizeof(t_cmd)); tmp_fd = handle_fd(input_split, i, tmp_fd, &(element->fd_in), &(element->fd_out)); element->argv = ft_split(input_split[i], ' '); element->builtin = cmd_path(element->argv, envp); - cmd = ft_lstnew(element); + ft_lstadd_back(&cmd, ft_lstnew(element)); i++; } + return (cmd); } void shell_loop(t_all *c) { char *line_input; -// t_list *cmd; + t_list *cmd; + t_list *tmp; + t_cmd *tmp_cmd; // t_pipe *pipes; // int nb_pipes; // int **pipes_fd; @@ -244,9 +248,8 @@ void shell_loop(t_all *c) line_input = readline(c->prompt); if (line_input && *line_input) { - // cmd = parser(line_input); - parser(line_input, c->envp); -// exec_cmd(c, cmd); + cmd = parser(line_input, c->envp); + exec_cmd(c, cmd); // pipes = fill_pipes(line_input); // execute_cmd(c, pipes);