From a9055b4c662ef3ae8c660e3109a9a7761a9d763a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Fri, 25 Apr 2025 18:12:58 +0200 Subject: [PATCH] feat(redirection/group_cmd): handle redirections for group cmds --- src/executing/group_cmd/group_cmd_execute.c | 13 ++++++++-- test.sh | 27 +++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/executing/group_cmd/group_cmd_execute.c b/src/executing/group_cmd/group_cmd_execute.c index c7e7710..addc97b 100644 --- a/src/executing/group_cmd/group_cmd_execute.c +++ b/src/executing/group_cmd/group_cmd_execute.c @@ -6,24 +6,33 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/04 19:50:42 by khais #+# #+# */ -/* Updated: 2025/04/28 12:29:34 by khais ### ########.fr */ +/* Updated: 2025/04/28 12:56:52 by khais ### ########.fr */ /* */ /* ************************************************************************** */ #include "group_cmd_execute.h" #include "../cmd/cmd_execute.h" #include "../common/do_waitpid.h" +#include "../simple_cmd/handle_redirections.h" +#include "../simple_cmd/std_fds.h" #include void group_cmd_execute(t_group_cmd *cmd, t_minishell *app, bool should_exit) { - int pid; + int pid; + t_std_fds fds; pid = fork(); if (pid == 0) + { + handle_redirections(cmd->redirects, app, &fds); cmd_execute(cmd->cmd, app, true); + restore_std_fds(&fds); + } else + { do_waitpid(app, pid); + } if (should_exit) exit(app->last_return_value); } diff --git a/test.sh b/test.sh index 2135777..52b0e0b 100755 --- a/test.sh +++ b/test.sh @@ -1377,4 +1377,31 @@ expecting < outfile +ls +cat outfile +EOF +expecting <