fix(parsing/simple_cmd): report error the same way as everywhere else, prevent leak

This commit is contained in:
Khaïs COLIN 2025-04-16 15:24:42 +02:00
parent d652f32cff
commit ced979dd31
2 changed files with 11 additions and 2 deletions

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */ /* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/15 10:38:47 by khais #+# #+# */ /* Created: 2025/04/15 10:38:47 by khais #+# #+# */
/* Updated: 2025/04/15 14:15:02 by khais ### ########.fr */ /* Updated: 2025/04/16 15:26:54 by khais ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -42,6 +42,6 @@ t_cmd *minishell_simple_cmd_parse(t_minishell *app, t_wordlist **tokens)
t_redirect_add_back(&simple->value.simple->redirections, redir); t_redirect_add_back(&simple->value.simple->redirections, redir);
} }
if (!simple->value.simple->words) if (!simple->value.simple->words)
return (cmd_destroy(simple), parse_error(app, (*tokens)->word), NULL); return (cmd_destroy(simple), ft_errno(FT_EERRNO), NULL);
return (simple); return (simple);
} }

View file

@ -626,4 +626,13 @@ minishell: syntax error near unexpected token `>'
2 2
EOF EOF
when_run <<EOF "single pipe char"
|
echo \$?
EOF
expecting <<"EOF"
minishell: syntax error near unexpected token `|'
2
EOF
finalize finalize