From d53e40d3f4b7f0caa403519a4169376e1f5ce860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Wed, 16 Apr 2025 17:36:51 +0200 Subject: [PATCH] fix(subst/variable): invalid identifiers were having their $ swallowed It is safe to delete this part: ```c if (!rep) return (NULL); ``` because rep is always returned, and no other code depends on that value --- src/subst/variable_subst.c | 8 ++++---- test.sh | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/subst/variable_subst.c b/src/subst/variable_subst.c index 9415519..96f903f 100644 --- a/src/subst/variable_subst.c +++ b/src/subst/variable_subst.c @@ -5,8 +5,8 @@ /* +:+ +:+ +:+ */ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2025/03/19 17:28/29 by khais #+# #+# */ -/* Updated: 2025/03/24 10:52:10 by jguelen ### ########.fr */ +/* Created: 2025/03/19 17:28:29 by khais #+# #+# */ +/* Updated: 2025/04/16 17:45:36 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -95,9 +95,9 @@ static char *calculate_replacement(t_worddesc *word, t_minishell *app, size_t i, { *id_len = 1; rep = expand_question_mark(app); - if (!rep) - return (NULL); } + else if (*id_len == 0) + return (free(id), ft_strdup("$")); else { rep = env_get_val(app->env, id); diff --git a/test.sh b/test.sh index dbf2a1c..09202fe 100755 --- a/test.sh +++ b/test.sh @@ -658,4 +658,20 @@ expecting <