mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-05 23:18:08 +01:00
Behaviour seems inconsistent
This commit is contained in:
parent
497f442d77
commit
e5952b3f43
4 changed files with 53 additions and 7 deletions
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* wordsplit_utils.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/20 14:02:29 by khais #+# #+# */
|
||||
/* Updated: 2025/04/09 13:34:02 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/26 15:07:17 by jguelen ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/20 15:01:38 by jguelen #+# #+# */
|
||||
/* Updated: 2025/04/25 18:54:06 by jguelen ### ########.fr */
|
||||
/* Updated: 2025/04/26 15:18:35 by jguelen ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -173,5 +173,8 @@ t_wordlist *expand_star(t_worddesc *file_pattern)
|
|||
clean_pattern(pattern_copy);
|
||||
expanded = expand_star_core(pattern_copy);
|
||||
worddesc_destroy(pattern_copy);
|
||||
return (expanded);
|
||||
if (ft_strcmp(expanded->word->word, file_pattern->word))
|
||||
return (expanded);
|
||||
wordlist_destroy(expanded);
|
||||
return (NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/15 15:09:56 by jguelen #+# #+# */
|
||||
/* Updated: 2025/04/25 18:53:04 by jguelen ### ########.fr */
|
||||
/* Updated: 2025/04/26 15:06:41 by jguelen ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -66,6 +66,15 @@ int ispattern(t_worddesc *desc)
|
|||
return (0);
|
||||
}
|
||||
|
||||
static char pattern_marker_quote_flip(char c, char *quote)
|
||||
{
|
||||
if (*quote == c)
|
||||
*quote = '\0';
|
||||
else if (*quote == '\0')
|
||||
*quote = c;
|
||||
return (*quote);
|
||||
}
|
||||
|
||||
t_worddesc *deal_with_potential_pattern_marker(t_worddesc *file_pattern)
|
||||
{
|
||||
t_worddesc *pattern_copy;
|
||||
|
|
@ -73,12 +82,20 @@ t_worddesc *deal_with_potential_pattern_marker(t_worddesc *file_pattern)
|
|||
char quote;
|
||||
|
||||
pattern_copy = worddesc_copy(file_pattern);
|
||||
if (!pattern_copy)
|
||||
return (NULL);
|
||||
if (file_pattern->flags & W_HASDOLLAR)
|
||||
{
|
||||
i = 0;
|
||||
quote = '\0';
|
||||
while (file_pattern->word[i])
|
||||
while (pattern_copy->word[i])
|
||||
{
|
||||
if (quote == '\0' || pattern_copy->word[i] == quote)
|
||||
pattern_copy->marker[i] = ' ';
|
||||
else
|
||||
pattern_copy->marker[i] = quote;
|
||||
if (pattern_copy->word[i] == '\'' || pattern_copy->word[i] == '"')
|
||||
pattern_marker_quote_flip(pattern_copy->word[i], "e);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
26
test.sh
26
test.sh
|
|
@ -1330,6 +1330,32 @@ expecting <<EOF
|
|||
hello
|
||||
hi
|
||||
0
|
||||
|
||||
when_run <<"EOF" "unquoting behaviour with wildcard"
|
||||
touch outfile
|
||||
export target="'out*'"
|
||||
echo $target
|
||||
ls
|
||||
EOF
|
||||
expecting <<EOF
|
||||
'out*'
|
||||
outfile
|
||||
EOF
|
||||
|
||||
when_run <<"EOF" "normal behaviour with wildcard before echo"
|
||||
export target=out*
|
||||
echo $target
|
||||
EOF
|
||||
expecting <<EOF
|
||||
outfile
|
||||
EOF
|
||||
|
||||
when_run <<"EOF" "normal behaviour with wildcard after variable expansion"
|
||||
export target="out*"
|
||||
echo $target
|
||||
EOF
|
||||
expecting <<EOF
|
||||
outfile
|
||||
EOF
|
||||
|
||||
finalize
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue