parsing ok
This commit is contained in:
17
srcs/main.c
17
srcs/main.c
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/04 05:59:26 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)
|
//t_list *parser(char *input)
|
||||||
void parser(char *input, char **envp)
|
t_list *parser(char *input, char **envp)
|
||||||
{
|
{
|
||||||
t_list *cmd;
|
t_list *cmd;
|
||||||
t_cmd *element;
|
t_cmd *element;
|
||||||
@@ -216,21 +216,25 @@ void parser(char *input, char **envp)
|
|||||||
input_split = ft_split(input, '|');
|
input_split = ft_split(input, '|');
|
||||||
tmp_fd = 0;
|
tmp_fd = 0;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
cmd = NULL;
|
||||||
while (input_split[i])
|
while (input_split[i])
|
||||||
{
|
{
|
||||||
element = calloc(1, sizeof(t_cmd));
|
element = calloc(1, sizeof(t_cmd));
|
||||||
tmp_fd = handle_fd(input_split, i, tmp_fd, &(element->fd_in), &(element->fd_out));
|
tmp_fd = handle_fd(input_split, i, tmp_fd, &(element->fd_in), &(element->fd_out));
|
||||||
element->argv = ft_split(input_split[i], ' ');
|
element->argv = ft_split(input_split[i], ' ');
|
||||||
element->builtin = cmd_path(element->argv, envp);
|
element->builtin = cmd_path(element->argv, envp);
|
||||||
cmd = ft_lstnew(element);
|
ft_lstadd_back(&cmd, ft_lstnew(element));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
return (cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shell_loop(t_all *c)
|
void shell_loop(t_all *c)
|
||||||
{
|
{
|
||||||
char *line_input;
|
char *line_input;
|
||||||
// t_list *cmd;
|
t_list *cmd;
|
||||||
|
t_list *tmp;
|
||||||
|
t_cmd *tmp_cmd;
|
||||||
// t_pipe *pipes;
|
// t_pipe *pipes;
|
||||||
// int nb_pipes;
|
// int nb_pipes;
|
||||||
// int **pipes_fd;
|
// int **pipes_fd;
|
||||||
@@ -244,9 +248,8 @@ void shell_loop(t_all *c)
|
|||||||
line_input = readline(c->prompt);
|
line_input = readline(c->prompt);
|
||||||
if (line_input && *line_input)
|
if (line_input && *line_input)
|
||||||
{
|
{
|
||||||
// cmd = parser(line_input);
|
cmd = parser(line_input, c->envp);
|
||||||
parser(line_input, c->envp);
|
exec_cmd(c, cmd);
|
||||||
// exec_cmd(c, cmd);
|
|
||||||
// pipes = fill_pipes(line_input);
|
// pipes = fill_pipes(line_input);
|
||||||
// execute_cmd(c, pipes);
|
// execute_cmd(c, pipes);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user