fix: invalid syntax error cause shown when there was no token following a redirection

This commit is contained in:
2026-02-12 02:57:15 +01:00
parent ac4965ca6d
commit 843bdc0061
2 changed files with 5 additions and 4 deletions

View File

@@ -6,7 +6,7 @@
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */ /* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2026/02/10 22:22:06 by sede-san #+# #+# */ /* Created: 2026/02/10 22:22:06 by sede-san #+# #+# */
/* Updated: 2026/02/11 02:30:32 by sede-san ### ########.fr */ /* Updated: 2026/02/12 02:55:36 by sede-san ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -18,9 +18,10 @@ void syntax_error_unexpected_token(
{ {
char *cause; char *cause;
cause = token->value;
if (token == NULL) if (token == NULL)
cause = "newline"; cause = "newline";
else
cause = token->value;
ft_eprintf("minishell: syntax error near unexpected token `%s'\n", cause); ft_eprintf("minishell: syntax error near unexpected token `%s'\n", cause);
} }

View File

@@ -6,7 +6,7 @@
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */ /* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/10/22 18:37:38 by sede-san #+# #+# */ /* Created: 2025/10/22 18:37:38 by sede-san #+# #+# */
/* Updated: 2026/02/11 10:08:22 by sede-san ### ########.fr */ /* Updated: 2026/02/12 02:55:51 by sede-san ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -148,7 +148,7 @@ t_redirection *redirection_new(
if (*tokens == NULL) if (*tokens == NULL)
{ {
free(redirection); free(redirection);
return (syntax_error_unexpected_token(token), NULL); return (syntax_error_unexpected_token(NULL), NULL);
} }
token = (t_token *)(*tokens)->content; token = (t_token *)(*tokens)->content;
if (token->type != TOKEN_WORD) if (token->type != TOKEN_WORD)