mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
fix(executing): return code on unknown cmd was unchanged, is now set to 127
This commit is contained in:
parent
9a32220945
commit
18225f3356
2 changed files with 8 additions and 3 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/03/27 16:21:56 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 "../../postprocess/expansion/expand_wildcard.h"
|
||||||
#include "simple_cmd_execute_debug.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",
|
ft_dprintf(STDERR_FILENO, "minishell: %s: command not found\n",
|
||||||
cmd->words->word->word);
|
cmd->words->word->word);
|
||||||
|
app->last_return_value = 127;
|
||||||
}
|
}
|
||||||
|
|
||||||
static t_redirect *do_redirection(t_redirect *redirection)
|
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);
|
exe = get_cmdpath(cmd->words->word->word, app);
|
||||||
if (exe == NULL)
|
if (exe == NULL)
|
||||||
{
|
{
|
||||||
command_not_found(cmd);
|
command_not_found(cmd, app);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
pid = fork();
|
pid = fork();
|
||||||
|
|
|
||||||
4
test.sh
4
test.sh
|
|
@ -195,11 +195,15 @@ EOF
|
||||||
|
|
||||||
when_run <<EOF "unknown commands"
|
when_run <<EOF "unknown commands"
|
||||||
qwertyuiop
|
qwertyuiop
|
||||||
|
echo \$?
|
||||||
poiuytrewq
|
poiuytrewq
|
||||||
|
echo \$?
|
||||||
EOF
|
EOF
|
||||||
expecting <<EOF
|
expecting <<EOF
|
||||||
minishell: qwertyuiop: command not found
|
minishell: qwertyuiop: command not found
|
||||||
|
127
|
||||||
minishell: poiuytrewq: command not found
|
minishell: poiuytrewq: command not found
|
||||||
|
127
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
when_run <<EOF "pwd works"
|
when_run <<EOF "pwd works"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue