|
@ -6,7 +6,7 @@ |
|
|
/* By: mea <marvin@42.fr> +#+ +:+ +#+ */ |
|
|
/* By: mea <marvin@42.fr> +#+ +:+ +#+ */ |
|
|
/* +#+#+#+#+#+ +#+ */ |
|
|
/* +#+#+#+#+#+ +#+ */ |
|
|
/* Created: 2022/05/02 12:14:09 by narnaud #+# #+# */ |
|
|
/* Created: 2022/05/02 12:14:09 by narnaud #+# #+# */ |
|
|
/* Updated: 2022/05/05 14:02:48 by mea ### ########.fr */ |
|
|
/* Updated: 2022/05/05 14:18:16 by mea ### ########.fr */ |
|
|
/* */ |
|
|
/* */ |
|
|
/* ************************************************************************** */ |
|
|
/* ************************************************************************** */ |
|
|
|
|
|
|
|
@ -64,7 +64,7 @@ int caller(t_datas *datas, t_command *cmd) |
|
|
return (1); |
|
|
return (1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
t_command *parser(t_token *tok, t_command *prev) |
|
|
t_command *parser(t_datas *datas, t_token *tok, t_command *prev) |
|
|
{ |
|
|
{ |
|
|
int i; |
|
|
int i; |
|
|
t_command *cmd; |
|
|
t_command *cmd; |
|
@ -79,7 +79,7 @@ t_command *parser(t_token *tok, t_command *prev) |
|
|
while(tok && tok->type != PIPE) |
|
|
while(tok && tok->type != PIPE) |
|
|
{ |
|
|
{ |
|
|
if (tok->type) |
|
|
if (tok->type) |
|
|
update_redir(cmd, tok); |
|
|
update_redir(datas, cmd, tok); |
|
|
else |
|
|
else |
|
|
cmd->argv[i++] = tok->value; |
|
|
cmd->argv[i++] = tok->value; |
|
|
tok = tok->next; |
|
|
tok = tok->next; |
|
@ -89,7 +89,7 @@ t_command *parser(t_token *tok, t_command *prev) |
|
|
cmd->argv[0], cmd->fd[0], cmd->fd[1]); |
|
|
cmd->argv[0], cmd->fd[0], cmd->fd[1]); |
|
|
cmd->argv[i] = NULL; |
|
|
cmd->argv[i] = NULL; |
|
|
if (tok && tok->type == PIPE) |
|
|
if (tok && tok->type == PIPE) |
|
|
cmd->next = parser(tok->next, cmd); |
|
|
cmd->next = parser(datas, tok->next, cmd); |
|
|
return(cmd); |
|
|
return(cmd); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -150,7 +150,7 @@ int main(int argc, char **argv, char **envp) |
|
|
halt(EXIT_FAILURE); |
|
|
halt(EXIT_FAILURE); |
|
|
if (is_empty(line)) |
|
|
if (is_empty(line)) |
|
|
continue ; |
|
|
continue ; |
|
|
caller(&datas, parser(lexer(&datas, line), NULL)); |
|
|
caller(&datas, parser(&datas, lexer(&datas, line), NULL)); |
|
|
add_history(line); |
|
|
add_history(line); |
|
|
} |
|
|
} |
|
|
clear_history(); |
|
|
clear_history(); |
|
|