Expansion: one fix to make sur $? is handled correctly

This commit is contained in:
Jérôme Guélen 2025-03-24 10:48:05 +01:00
parent 2a61706f1a
commit d5415d978c
No known key found for this signature in database

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */ /* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/19 17:28/29 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); *id_len = ft_strlen(id);
if (*id_len == 0 && word->word[i + 1] == '?') if (*id_len == 0 && word->word[i + 1] == '?')
{ {
*id_len = 1;
rep = expand_question_mark(app); rep = expand_question_mark(app);
if (!rep) if (!rep)
return (NULL); return (NULL);
@ -107,8 +108,7 @@ static char *calculate_replacement(t_worddesc *word, t_minishell *app, size_t i,
if (!rep) if (!rep)
return (NULL); return (NULL);
} }
free(id); return (free(id), rep);
return (rep);
} }
/* /*