From d1681dafe3bb7a6c44d70be79e435bbd16ed3ce7 Mon Sep 17 00:00:00 2001 From: tom moron Date: Wed, 8 May 2024 11:57:49 +0200 Subject: [PATCH] fix is_var --- srcs/minishell.h | 4 ++-- srcs/parsing_var.c | 5 +++-- srcs/variable_expantion.c | 5 ++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/srcs/minishell.h b/srcs/minishell.h index b3d3508..468b037 100755 --- a/srcs/minishell.h +++ b/srcs/minishell.h @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */ -/* Updated: 2024/05/07 17:34:59 by tomoron ### ########.fr */ +/* Updated: 2024/05/08 11:56:37 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -81,7 +81,7 @@ typedef struct s_msh extern int g_return_code; int get_in_type(t_msh *msh, t_cmd *t_strt, t_cmd *tokens, int here_doc); -int add_var_to_str(char *res, char **command, t_env *env, int dquote); +int add_var_to_str(char *res, char **cmd, t_env *env, int quote, int *i_v); t_env *export_set_env(t_env *env, char *name, char *value, int append); t_env *env_add_back(t_env *env, char *name, char *value, int empty); void parent(t_msh *msh, int i, int cmd_count, char **cmd_args); diff --git a/srcs/parsing_var.c b/srcs/parsing_var.c index 1a6b04c..c9f8e14 100755 --- a/srcs/parsing_var.c +++ b/srcs/parsing_var.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/09 15:24:36 by tomoron #+# #+# */ -/* Updated: 2024/05/06 16:27:54 by tomoron ### ########.fr */ +/* Updated: 2024/05/08 11:55:37 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -85,7 +85,7 @@ int invalid_variable_char(char *res, char c) return (2); } -int add_var_to_str(char *res, char **command, t_env *env, int dquote) +int add_var_to_str(char *res, char **command, t_env *env, int dquote, int *i_v) { char *var_name; char *var; @@ -93,6 +93,7 @@ int add_var_to_str(char *res, char **command, t_env *env, int dquote) i = 0; (*command)++; + *i_v = 1; if (**command == '\'' || **command == '"' || !**command) { if ((**command != '\'' && **command != '"') || dquote) diff --git a/srcs/variable_expantion.c b/srcs/variable_expantion.c index a66f659..833fd46 100644 --- a/srcs/variable_expantion.c +++ b/srcs/variable_expantion.c @@ -6,7 +6,7 @@ /* By: tomoron +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/06 10:57:33 by tomoron #+# #+# */ -/* Updated: 2024/05/06 10:57:39 by tomoron ### ########.fr */ +/* Updated: 2024/05/08 11:54:17 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" @@ -47,7 +47,6 @@ char *expand_variables(char *command, t_env *env, int *is_var) res = ft_calloc(get_variable_expantion_len(command, env) + 1, 1); in_quote = 0; in_dquote = 0; - *is_var = 1; i = 0; while (res && *command) { @@ -56,7 +55,7 @@ char *expand_variables(char *command, t_env *env, int *is_var) if (*command == '"' && !in_quote) in_dquote = !in_dquote; if (*command == '$' && !in_quote) - i += add_var_to_str(res + i, &command, env, in_dquote); + i += add_var_to_str(res + i, &command, env, in_dquote, is_var); else res[i++] = *command; command++;