parsing: fix redir accepting operators as specifiers

before:
$ >>>>>
minishell: syntax error near unexpected token `newline'

after:
$ >>>>>
minishell: syntax error near unexpected token `>>'

>> is now correctly detected as an operator, and not a word
This commit is contained in:
Khaïs COLIN 2025-04-16 13:56:36 +02:00
parent 9593851149
commit 84a246f6f6

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/15 10:13:58 by khais #+# #+# */
/* Updated: 2025/04/16 12:58:04 by khais ### ########.fr */
/* Updated: 2025/04/16 13:56:59 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -32,10 +32,12 @@ t_redirect *minishell_redirect_parse(t_minishell *app, t_wordlist **tokens)
if ((*tokens) == NULL)
{
worddesc_destroy(redir_operator);
ft_errno(FT_EERRNO);
return (redirect_destroy(redir_list), NULL);
return (ft_errno(FT_EERRNO), redirect_destroy(redir_list), NULL);
}
redir_specifier = wordlist_pop(tokens);
if ((*tokens)->word->token_type == WORD_TOKEN)
redir_specifier = wordlist_pop(tokens);
else
return (ft_errno(FT_EERRNO), redirect_destroy(redir_list), NULL);
new_redir = redir_from_words(redir_operator, redir_specifier, app);
t_redirect_add_back(&redir_list, new_redir);
}