From b95ba5d1ffb8075c9945ddfa047d8fabb1df20c3 Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Fri, 23 Aug 2024 16:19:22 +0200 Subject: [PATCH] Fix showing single quotes upon expansion In order for the wildcard expanded words not to be expanded again as variables, single quotes were used for variable expansion. This however caused single quotes to show when variable was expanded inside double quotes. The solution is to only quote the variables in wildcard expansion. --- inc/minishell.h | 4 ++-- src/execution.c | 26 +++++++++++++++----------- src/wildcards.c | 4 ++-- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/inc/minishell.h b/inc/minishell.h index 43f0a29..6f30ad7 100644 --- a/inc/minishell.h +++ b/inc/minishell.h @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/02 13:22:57 by ljiriste #+# #+# */ -/* Updated: 2024/08/22 14:25:59 by ljiriste ### ########.fr */ +/* Updated: 2024/08/23 16:15:16 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -55,7 +55,7 @@ void clean_env(t_execution_env *env); void handle_input(char **line, t_execution_env *env); void unquote_field(char *field); -int add_word(t_vec *exp_str, const char *word, const t_execution_env *env); +int add_word(t_vec *exp_str, const char *word, const t_execution_env *env, int quote); int add_conformant(t_vec *expanded, t_wildcard_info *info, char quote); int expand_dir(t_vec *expanded, t_wildcard_info *info); diff --git a/src/execution.c b/src/execution.c index 2832e07..b8dd626 100644 --- a/src/execution.c +++ b/src/execution.c @@ -6,7 +6,7 @@ /* By: lnikolov token.str, env)) + if (add_word(exp_str, subnode->token.str, env, 0)) return (1); ++i; } diff --git a/src/wildcards.c b/src/wildcards.c index 709dcec..e386bc7 100644 --- a/src/wildcards.c +++ b/src/wildcards.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/08 10:50:26 by ljiriste #+# #+# */ -/* Updated: 2024/08/23 14:03:58 by ljiriste ### ########.fr */ +/* Updated: 2024/08/23 16:15:58 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -200,7 +200,7 @@ int expand_vars(char **str, const t_execution_env *env) if (ft_vec_init(&expanded, sizeof(char)) != success) return (1); - if (add_word(&expanded, *str, env)) + if (add_word(&expanded, *str, env, 1)) { ft_vec_free(&expanded, NULL); return (1); -- 2.30.2