From: Lukáš Jiřiště Date: Tue, 27 Aug 2024 08:07:46 +0000 (+0200) Subject: Fix setting another value to exported variable X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=7d83204;p=42%2Fminishell.git Fix setting another value to exported variable Instead of setting an exported variable to new value with the command of the form = a new non-exported variable was created and used for variable expasion. The exported value was passed to child processes. This behaviour is fixed by this commit to the expected setting of exported variable to the new value. --- diff --git a/src/execution.c b/src/execution.c index 1e41ab9..775cf77 100644 --- a/src/execution.c +++ b/src/execution.c @@ -6,7 +6,7 @@ /* By: lnikolov vars->other, assignments->vec, assignments->size, 0) == success); + size_t i; + const char *var_line; + char *var_name; + + i = 0; + while (i < assignments->size) + { + var_line = ft_vec_caccess(assignments, i); + var_name = get_var_name(var_line); + if (!var_name) + return (1); + if (set_env_var_value(env, var_name, var_line + ft_strlen(var_name) + 1)) + { + free(var_name); + return (1); + } + free(var_name); + ++i; + } + return (0); } void free_split(char **fields)