fix(parsing): report unclosed ( error

This commit is contained in:
Khaïs COLIN 2025-04-25 13:17:29 +02:00
parent 527a624765
commit 0c9dcd944e
2 changed files with 21 additions and 3 deletions

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* cmd_parsing.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/31 10:28:28 by jguelen #+# #+# */
/* Updated: 2025/04/24 16:39:14 by jguelen ### ########.fr */
/* Updated: 2025/04/25 13:17:56 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -65,7 +65,7 @@ t_cmd *minishell_parse(t_minishell *app, char *command_line)
if (!tokens)
return (expecting_quote_error(app));
root_cmd = minishell_cmds_parse(app, &tokens);
if (root_cmd == NULL && ft_errno_get() != FT_ESUCCESS)
if ((root_cmd == NULL && ft_errno_get() != FT_ESUCCESS) || tokens != NULL)
{
if (tokens == NULL)
parse_error_newline(app);

18
test.sh
View file

@ -1021,4 +1021,22 @@ minishell: cat: Permission denied
126
EOF
when_run <<EOF "unclosed ("
(echo unclosed paren
EOF
expecting <<"EOF"
minishell: syntax error near unexpected token `newline'
EOF
when_run <<"EOF" "unclosed ( in export"
export VAR=bon(jour
echo $?
echo var=$VAR
EOF
expecting <<"EOF"
minishell: syntax error near unexpected token `('
2
var=
EOF
finalize