From d5415d978c0c8e730c989b1468f76d6c84810c61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gu=C3=A9len?= Date: Mon, 24 Mar 2025 10:48:05 +0100 Subject: [PATCH] Expansion: one fix to make sur $? is handled correctly --- src/subst/variable_subst.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/subst/variable_subst.c b/src/subst/variable_subst.c index 795aea1..4d32dda 100644 --- a/src/subst/variable_subst.c +++ b/src/subst/variable_subst.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/19 17:28/29 by khais #+# #+# */ -/* Updated: 2025/03/21 17:38:16 by jguelen ### ########.fr */ +/* Updated: 2025/03/24 10:47:12 by jguelen ### ########.fr */ /* */ /* ************************************************************************** */ @@ -93,6 +93,7 @@ static char *calculate_replacement(t_worddesc *word, t_minishell *app, size_t i, *id_len = ft_strlen(id); if (*id_len == 0 && word->word[i + 1] == '?') { + *id_len = 1; rep = expand_question_mark(app); if (!rep) return (NULL); @@ -107,8 +108,7 @@ static char *calculate_replacement(t_worddesc *word, t_minishell *app, size_t i, if (!rep) return (NULL); } - free(id); - return (rep); + return (free(id), rep); } /*