From 713f0f03022723ffbc0eb5a3804c806cdfe3b629 Mon Sep 17 00:00:00 2001 From: EniumRaphael Date: Mon, 13 May 2024 12:48:23 +0200 Subject: [PATCH] Pushing ohter sep --- sources/exec/separator/and_and.c | 21 +++++++++++++++++++++ sources/exec/separator/pipe_pipe.c | 23 +++++++++++++++++++++++ sources/exec/separator/semicolon.c | 9 +-------- sources/exec/separator/separator.h | 4 +++- sources/exec/separator/simple_cmd.c | 20 ++++++++++++++++++++ 5 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 sources/exec/separator/and_and.c create mode 100644 sources/exec/separator/pipe_pipe.c create mode 100644 sources/exec/separator/simple_cmd.c diff --git a/sources/exec/separator/and_and.c b/sources/exec/separator/and_and.c new file mode 100644 index 00000000..224c2229 --- /dev/null +++ b/sources/exec/separator/and_and.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* and_and.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/12 19:16:12 by rparodi #+# #+# */ +/* Updated: 2024/05/12 19:19:08 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "separator.h" + +t_error and_and_exec(t_node *first, t_node *second, t_i32 *ret_value) +{ + if (ft_command_exec(first, ret_value) == ERROR) + return (ERROR); + ft_command_exec(second, ret_value); + return (NO_ERROR); +} diff --git a/sources/exec/separator/pipe_pipe.c b/sources/exec/separator/pipe_pipe.c new file mode 100644 index 00000000..fefc06ff --- /dev/null +++ b/sources/exec/separator/pipe_pipe.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* pipe_pipe.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/12 19:21:01 by rparodi #+# #+# */ +/* Updated: 2024/05/12 19:44:46 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "separator.h" + +t_error pipe_pipe(t_node *first, t_node *second, t_i32 *ret_value) +{ + if (first || ft_command_exec(first, ret_value)) + return (NO_ERROR); + else if (second || ft_command_exec(second, ret_value)) + return (NO_ERROR); + else + return (ERROR); +} diff --git a/sources/exec/separator/semicolon.c b/sources/exec/separator/semicolon.c index 1b7e1fb7..1f9f3ba4 100644 --- a/sources/exec/separator/semicolon.c +++ b/sources/exec/separator/semicolon.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/12 16:00:33 by rparodi #+# #+# */ -/* Updated: 2024/05/12 16:21:34 by rparodi ### ########.fr */ +/* Updated: 2024/05/12 19:13:26 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,13 +21,6 @@ #include "minishell.h" #include "me/string/str_clone.h" -t_error ft_command_exec(t_node *node, t_i32 *ret_value) -{ - printf("execve : %s\n", node->single_str); - - return (NO_ERROR); -} - t_error semicolon_exec(t_node *first, t_node *second, t_i32 *ret_value) { if (!first && !second) diff --git a/sources/exec/separator/separator.h b/sources/exec/separator/separator.h index f8c924b6..d52a118c 100644 --- a/sources/exec/separator/separator.h +++ b/sources/exec/separator/separator.h @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/12 16:53:15 by rparodi #+# #+# */ -/* Updated: 2024/05/12 16:54:01 by rparodi ### ########.fr */ +/* Updated: 2024/05/12 19:57:14 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,6 +16,8 @@ # include "minishell.h" t_error ft_command_exec(t_node *node, t_i32 *ret_value); +t_error pipe_pipe(t_node *first, t_node *second, t_i32 *ret_value); +t_error and_and_exec(t_node *first, t_node *second, t_i32 *ret_value); t_error semicolon_exec(t_node *first, t_node *second, t_i32 *ret_value); #endif diff --git a/sources/exec/separator/simple_cmd.c b/sources/exec/separator/simple_cmd.c new file mode 100644 index 00000000..92bb46a1 --- /dev/null +++ b/sources/exec/separator/simple_cmd.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* simple_cmd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/12 19:13:42 by rparodi #+# #+# */ +/* Updated: 2024/05/12 19:14:19 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "separator.h" + +t_error ft_command_exec(t_node *node, t_i32 *ret_value) +{ + printf("execve : %s\n", node->single_str); + + return (NO_ERROR); +}