From 7d83204207a2bc012b3f2c75ac61a84a7ea4c7e9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Luk=C3=A1=C5=A1=20Ji=C5=99i=C5=A1t=C4=9B?= Date: Tue, 27 Aug 2024 10:07:46 +0200 Subject: [PATCH] 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. --- src/execution.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) 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) -- 2.30.2