From 18225f3356b88b9cf53d006f858915a7b1539369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Wed, 16 Apr 2025 14:59:22 +0200 Subject: [PATCH] fix(executing): return code on unknown cmd was unchanged, is now set to 127 --- src/executing/simple_cmd/simple_cmd_execute.c | 7 ++++--- test.sh | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/executing/simple_cmd/simple_cmd_execute.c b/src/executing/simple_cmd/simple_cmd_execute.c index 9c28d06..b1116b4 100644 --- a/src/executing/simple_cmd/simple_cmd_execute.c +++ b/src/executing/simple_cmd/simple_cmd_execute.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/27 16:21:56 by khais #+# #+# */ -/* Updated: 2025/04/15 15:33:50 by khais ### ########.fr */ +/* Updated: 2025/04/16 14:59:11 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,10 +27,11 @@ #include "../../postprocess/expansion/expand_wildcard.h" #include "simple_cmd_execute_debug.h" -static void command_not_found(t_simple_cmd *cmd) +static void command_not_found(t_simple_cmd *cmd, t_minishell *app) { ft_dprintf(STDERR_FILENO, "minishell: %s: command not found\n", cmd->words->word->word); + app->last_return_value = 127; } static t_redirect *do_redirection(t_redirect *redirection) @@ -101,7 +102,7 @@ void simple_cmd_execute(t_simple_cmd *cmd, t_minishell *app) exe = get_cmdpath(cmd->words->word->word, app); if (exe == NULL) { - command_not_found(cmd); + command_not_found(cmd, app); return ; } pid = fork(); diff --git a/test.sh b/test.sh index f83ff4c..a432b3c 100755 --- a/test.sh +++ b/test.sh @@ -195,11 +195,15 @@ EOF when_run <