diff --git a/src/executing/simple_cmd/simple_cmd_execute.c b/src/executing/simple_cmd/simple_cmd_execute.c index 92f6570..985cb33 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/28 14:42:13 by khais ### ########.fr */ +/* Updated: 2025/04/28 15:57:23 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -81,14 +81,17 @@ static void exec_external_cmd(t_simple_cmd *cmd, t_minishell *app, if (cmd->words == NULL) return (restore_std_fds(fds)); exe = get_cmdpath(cmd->words->word->word, app); - if (exe == NULL) - return (command_not_found(cmd, app)); - pid = fork(); - if (pid == 0) - execute_subprocess(exe, cmd, app, fds); + if (exe != NULL) + { + pid = fork(); + if (pid == 0) + execute_subprocess(exe, cmd, app, fds); + free(exe); + do_waitpid(app, pid); + } restore_std_fds(fds); - free(exe); - do_waitpid(app, pid); + if (exe == NULL) + command_not_found(cmd, app); } void simple_cmd_execute(t_simple_cmd *cmd, t_minishell *app, diff --git a/test.sh b/test.sh index 7add031..280d9e7 100755 --- a/test.sh +++ b/test.sh @@ -1449,4 +1449,13 @@ hi hello EOF +when_run < bonjour +ls +EOF +expecting <