diff --git a/srcs/exec/pipeline.c b/srcs/exec/pipeline.c index e8d61d2..150a4ca 100644 --- a/srcs/exec/pipeline.c +++ b/srcs/exec/pipeline.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/11/16 01:57:38 by lperrey #+# #+# */ -/* Updated: 2021/12/11 05:24:07 by lperrey ### ########.fr */ +/* Updated: 2021/12/16 15:55:36 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -73,7 +73,7 @@ static int pipeline_find_access(t_cmd *pipeline[], char *path[]) i = 0; while (pipeline[i]) { - if (!pipeline[i]->error) + if (!pipeline[i]->error && pipeline[i]->argv[0]) { if (!cmd_find_access(pipeline[i], path)) return (0); @@ -91,7 +91,7 @@ static pid_t pipeline_exec(t_cmd *pipeline[], t_all *c) i = 0; while (pipeline[i]) { - if (!pipeline[i]->error) + if (!pipeline[i]->error && pipeline[i]->argv[0]) { ret = cmd_exec_in_subshell(pipeline[i], c); if (ret != EXIT_SUCCESS) diff --git a/srcs/parsing/parsing.c b/srcs/parsing/parsing.c index 3a9755e..eb9df80 100644 --- a/srcs/parsing/parsing.c +++ b/srcs/parsing/parsing.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/24 10:52:40 by lperrey #+# #+# */ -/* Updated: 2021/12/16 04:58:12 by lperrey ### ########.fr */ +/* Updated: 2021/12/16 16:23:09 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -93,6 +93,7 @@ command : cmd_prefix cmd_name cmd_suffix | cmd_prefix cmd_name | cmd_name cmd_suffix | cmd_name + | cmd_prefix ; cmd_name : WORD // Apply rule 7a ; diff --git a/srcs/parsing/valid_syntax/valid_command.c b/srcs/parsing/valid_syntax/valid_command.c index eafb625..cee3bc5 100644 --- a/srcs/parsing/valid_syntax/valid_command.c +++ b/srcs/parsing/valid_syntax/valid_command.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/24 18:52:05 by lperrey #+# #+# */ -/* Updated: 2021/10/24 19:21:28 by lperrey ### ########.fr */ +/* Updated: 2021/12/17 03:14:06 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,6 +18,7 @@ static int valid_command_rule1(t_token **token_list); static int valid_command_rule2(t_token **token_list); static int valid_command_rule3(t_token **token_list); static int valid_command_rule4(t_token **token_list); +static int valid_command_rule5(t_token **token_list); int valid_command(t_token **token_list) { @@ -35,6 +36,9 @@ int valid_command(t_token **token_list) *token_list = cmd_start; if (valid_command_rule4(token_list)) return (1); + *token_list = cmd_start; + if (valid_command_rule5(token_list)) + return (1); return (0); } @@ -94,3 +98,14 @@ static int valid_command_rule4(t_token **token_list) } return (0); } + +// cmd_prefix +static int valid_command_rule5(t_token **token_list) +{ + while (valid_io_redirect(token_list)) + { + if (valid_command_separator(*token_list)) + return (1); + } + return (0); +}