mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
command list parse: handle two commands separated by ||
This commit is contained in:
parent
36fa53131a
commit
e6dd1d6a56
2 changed files with 17 additions and 2 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/24 17:40:48 by khais #+# #+# */
|
||||
/* Updated: 2025/02/25 13:26:14 by khais ### ########.fr */
|
||||
/* Updated: 2025/02/25 13:32:27 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
static t_command_list *parse_command_list(char *input)
|
||||
{
|
||||
ft_dprintf(STDERR_FILENO, "Now checking command list with input [%s]\n", input);
|
||||
t_wordlist *words = minishell_wordsplit(input);
|
||||
t_command_list *cmd = command_list_from_wordlist(words);
|
||||
return (cmd);
|
||||
|
|
@ -98,10 +99,22 @@ static void test_parse_command_list_simple_and(void)
|
|||
command_list_destroy(cmd);
|
||||
}
|
||||
|
||||
static void test_parse_command_list_simple_or(void)
|
||||
{
|
||||
t_command_list *cmd = parse_command_list("echo this | cat -e || echo works | wc -c");
|
||||
assert(cmd != NULL);
|
||||
assert_pipelineequal("echo this | cat -e", cmd, 0);
|
||||
assert_pipelineequal("echo works | wc -c", cmd, 1);
|
||||
assert(cmd->operator == OP_OR);
|
||||
assert(cmd->num_pipelines == 2);
|
||||
command_list_destroy(cmd);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
test_parse_command_list_empty();
|
||||
test_parse_command_list_single_pipeline();
|
||||
test_parse_command_list_simple_and();
|
||||
test_parse_command_list_simple_or();
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue