mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
fix(expansion/wildcard): do not remove quotes twice on non-pattern strings
There is still an issue with removing too many quotes when expanding variables (see #138). This will be tackled in a later PR.
This commit is contained in:
parent
aca85c3583
commit
2180909285
4 changed files with 19 additions and 5 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/03/27 16:21:56 by khais #+# #+# */
|
/* Created: 2025/03/27 16:21:56 by khais #+# #+# */
|
||||||
/* Updated: 2025/04/21 08:45:05 by khais ### ########.fr */
|
/* Updated: 2025/04/22 13:14:33 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -43,13 +43,16 @@ static t_simple_cmd *post_process_command(t_simple_cmd *cmd, t_minishell *app)
|
||||||
simple_cmd_post_process_debug(cmd, app);
|
simple_cmd_post_process_debug(cmd, app);
|
||||||
if (simple_cmd_expand_vars(cmd, app) == NULL)
|
if (simple_cmd_expand_vars(cmd, app) == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
simple_cmd_post_process_debug(cmd, app);
|
||||||
if (simple_cmd_fieldsplit(cmd) == NULL)
|
if (simple_cmd_fieldsplit(cmd) == NULL)
|
||||||
{
|
{
|
||||||
app->last_return_value = 1;
|
app->last_return_value = 1;
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
simple_cmd_post_process_debug(cmd, app);
|
||||||
if (simple_cmd_expand_wildcards(cmd) == NULL)
|
if (simple_cmd_expand_wildcards(cmd) == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
simple_cmd_post_process_debug(cmd, app);
|
||||||
if (simple_cmd_remove_quotes(cmd) == NULL)
|
if (simple_cmd_remove_quotes(cmd) == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
return (cmd);
|
return (cmd);
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* subst.h :+: :+: :+: */
|
/* subst.h :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/23 15:01:40 by jguelen #+# #+# */
|
/* Created: 2025/04/22 13:14/27 by khais #+# #+# */
|
||||||
/* Updated: 2025/03/21 18:47:30 by jguelen ### ########.fr */
|
/* Updated: 2025/04/22 13:14:27 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -43,5 +43,6 @@ void destroy_pattern_check(char **pattern_check, size_t len);
|
||||||
void build_pattern_checks(char *str, t_worddesc *pattern,
|
void build_pattern_checks(char *str, t_worddesc *pattern,
|
||||||
char **checker);
|
char **checker);
|
||||||
void clean_pattern(t_worddesc *file_pattern);
|
void clean_pattern(t_worddesc *file_pattern);
|
||||||
|
int ispattern(t_worddesc *desc);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/03/20 15:01:38 by jguelen #+# #+# */
|
/* Created: 2025/03/20 15:01:38 by jguelen #+# #+# */
|
||||||
/* Updated: 2025/04/08 16:31:46 by khais ### ########.fr */
|
/* Updated: 2025/04/22 13:18:18 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -168,6 +168,8 @@ char fits_pattern(char *str, t_worddesc *pattern)
|
||||||
*/
|
*/
|
||||||
t_wordlist *expand_star(t_worddesc *file_pattern)
|
t_wordlist *expand_star(t_worddesc *file_pattern)
|
||||||
{
|
{
|
||||||
|
if (!ispattern(file_pattern))
|
||||||
|
return (NULL);
|
||||||
clean_pattern(file_pattern);
|
clean_pattern(file_pattern);
|
||||||
return (expand_star_core(file_pattern));
|
return (expand_star_core(file_pattern));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
8
test.sh
8
test.sh
|
|
@ -928,4 +928,12 @@ expecting <<EOF
|
||||||
hello
|
hello
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
when_run <<"EOF" "unquoting behaviour"
|
||||||
|
export target="'outfile'"
|
||||||
|
echo $target
|
||||||
|
EOF
|
||||||
|
expecting <<EOF
|
||||||
|
'outfile'
|
||||||
|
EOF
|
||||||
|
|
||||||
finalize
|
finalize
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue