From 84a246f6f62a5331cce875567e0c2862416ae440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Wed, 16 Apr 2025 13:56:36 +0200 Subject: [PATCH] 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 --- src/parser/redirect/redirect_parse.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/parser/redirect/redirect_parse.c b/src/parser/redirect/redirect_parse.c index 31aaaf6..0edd9a5 100644 --- a/src/parser/redirect/redirect_parse.c +++ b/src/parser/redirect/redirect_parse.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); }