diff --git a/src/subst/variable_subst.c b/src/subst/variable_subst.c index 96f903f..1d04e6f 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/04/16 17:45:36 by khais ### ########.fr */ +/* Updated: 2025/04/16 18:03:52 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,11 +20,7 @@ ** word: the worddesc to be modified ** i: the index at which the $ marking the start of expansion is located ** id_len: the length of the string that constitutes a valid bash -** identifier (it is to be noted that it can be zero and yet still -** conduct to a replacement of more that just $ if $ is immediately -** followed by a digit -- this cans be modified as it is not strictly -** required to consider positionnal arguments at all or indeed treat -** them as holding no value) +** identifier ** rep: a malloc-allocated string previously calculated to correspond to ** the actual value to set as the expansion ** This function exists to actually modify the worddesc word by modifying the @@ -53,11 +49,9 @@ static t_worddesc *word_update(t_worddesc *word, size_t i, size_t id_len, { char *new_word; size_t rep_len; - size_t digit; - digit = ft_isdigit(word->word[i + 1]); rep_len = ft_strlen(rep); - new_word = replace_in_str(word->word, i, i + id_len + digit, rep); + new_word = replace_in_str(word->word, i, i + id_len, rep); free(rep); free(word->word); word->word = new_word; @@ -67,7 +61,7 @@ static t_worddesc *word_update(t_worddesc *word, size_t i, size_t id_len, rep = construct_repeting_char_string('$', rep_len); if (!rep) return (NULL); - new_word = replace_in_str(word->marker, i, i + id_len + digit, rep); + new_word = replace_in_str(word->marker, i, i + id_len, rep); free(rep); if (!new_word) return (NULL); @@ -118,9 +112,6 @@ static char *calculate_replacement(t_worddesc *word, t_minishell *app, size_t i, ** identifier with the corresponding value if present in env, the return value ** of the last foreground executed pipeline in the case of $? or nothing if ** the corresponding identifier does not have an entry in env. -** Additionnally if the first character following is a digit both the '$' -** and digit are removed even though we do not deal with those type of bash -** parameters (we consider them to never hold a value). ** Similarly if the character following the '$' is neither '_' or ** alphanumerical the dollar is removed except for the appearance of a '\0' ** signaling the end of the word. diff --git a/test.sh b/test.sh index 09202fe..0f0d8b4 100755 --- a/test.sh +++ b/test.sh @@ -674,4 +674,11 @@ expecting <