aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-07-02 11:33:08 +0100
committerRon Yorston <rmy@pobox.com>2024-07-02 11:33:08 +0100
commit480ebf43e85b2cfc31c433ee8bb3a723e44e9f9f (patch)
treea507d5487e1ae59bf4d12c5c30dbd2594dd9a6a5
parentfcb61f38cd937242882dd7ecdfbf3b4f68c18a8a (diff)
downloadbusybox-w32-480ebf43e85b2cfc31c433ee8bb3a723e44e9f9f.tar.gz
busybox-w32-480ebf43e85b2cfc31c433ee8bb3a723e44e9f9f.tar.bz2
busybox-w32-480ebf43e85b2cfc31c433ee8bb3a723e44e9f9f.zip
win32: properly restore BB_ env vars
Some BB_ shell variables get special treatment: they're updated in the environment immediately on any change. One case was missed: if such a variable was unset or not exported and was overridden by a local variable it wasn't unset in the environment when the local variable went out of scope. Add the code required to do this. Adds 48-64 bytes. (GitHub issue #423)
-rw-r--r--shell/ash.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 9ef8f7742..b894a2314 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -10948,6 +10948,9 @@ poplocalvars(int keep)
10948 struct localvar_list *ll; 10948 struct localvar_list *ll;
10949 struct localvar *lvp, *next; 10949 struct localvar *lvp, *next;
10950 struct var *vp; 10950 struct var *vp;
10951#if ENABLE_PLATFORM_MINGW32
10952 int var_type;
10953#endif
10951 10954
10952 INT_OFF; 10955 INT_OFF;
10953 ll = localvar_stack; 10956 ll = localvar_stack;
@@ -10991,8 +10994,15 @@ poplocalvars(int keep)
10991 vp->flags = lvp->flags; 10994 vp->flags = lvp->flags;
10992 vp->var_text = lvp->text; 10995 vp->var_text = lvp->text;
10993#if ENABLE_PLATFORM_MINGW32 10996#if ENABLE_PLATFORM_MINGW32
10994 if (is_bb_var(lvp->text) == BB_VAR_ASSIGN) 10997 var_type = is_bb_var(lvp->text);
10998 if (var_type == BB_VAR_ASSIGN && (lvp->flags & VEXPORT))
10995 putenv(lvp->text); 10999 putenv(lvp->text);
11000 else if (var_type) {
11001 char *var = xstrdup(lvp->text);
11002 *strchrnul(var, '=') = '\0';
11003 unsetenv(var);
11004 free(var);
11005 }
10996#endif 11006#endif
10997 } 11007 }
10998 free(lvp); 11008 free(lvp);