parsing: do not reset last_return_value at start of parsing

we need to preserve it, to be able to show the return value from the last command
This commit is contained in:
Khaïs COLIN 2025-04-15 15:44:14 +02:00
parent 1a949bdcab
commit 81ba53237c
4 changed files with 16 additions and 6 deletions

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/31 10:28:28 by jguelen #+# #+# */
/* Updated: 2025/04/15 14:15:49 by khais ### ########.fr */
/* Updated: 2025/04/15 15:43:50 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -105,7 +105,6 @@ t_cmd *minishell_parse(t_minishell *app, char *command_line)
t_wordlist *tokens;
ft_errno(FT_ESUCCESS);
app->last_return_value = 0;
if (!command_line)
return (NULL);
tokens = minishell_wordsplit(command_line);
@ -114,7 +113,7 @@ t_cmd *minishell_parse(t_minishell *app, char *command_line)
root_cmd = minishell_cmds_parse(app, &tokens);
if (!root_cmd)
{
if (ft_errno_get() != FT_ESUCCESS && !app->last_return_value)
if (ft_errno_get() != FT_ESUCCESS)
app->last_return_value = 1;
return (wordlist_destroy(tokens), NULL);
}