aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-07-08 14:49:31 +0100
committerRon Yorston <rmy@pobox.com>2024-07-08 14:49:31 +0100
commit29a24869e403e7364301e6fd7c745d327ed2d8c6 (patch)
tree3199a550aad823c727a5a4c58557653dc78c08ba
parentfff1c91e642f4d62e5dc542594e79b0972a3db78 (diff)
downloadbusybox-w32-29a24869e403e7364301e6fd7c745d327ed2d8c6.tar.gz
busybox-w32-29a24869e403e7364301e6fd7c745d327ed2d8c6.tar.bz2
busybox-w32-29a24869e403e7364301e6fd7c745d327ed2d8c6.zip
ash: restore value of imported variable on unexport
Shell variables imported from the environment are marked with a special flag and backslashes in their values are (by default) replaced with forward slashes. Sometimes this may not be what we want. Modify the 'export' shell built-in so unexporting a variable of this type restores its original value from the environment and removes its special flag. It can then be re-exported. Adds 32 bytes. (GitHub issue #428)
-rw-r--r--shell/ash.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c
index d9ab3feb5..64a8dd318 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -15512,6 +15512,15 @@ exportcmd(int argc UNUSED_PARAM, char **argv)
15512 } 15512 }
15513#endif 15513#endif
15514 vp->flags = ((vp->flags | flag) & flag_off); 15514 vp->flags = ((vp->flags | flag) & flag_off);
15515#if ENABLE_PLATFORM_MINGW32
15516 /* Unexporting a variable imported from the
15517 * environment restores its original value and
15518 * removes the VIMPORT flag. */
15519 if ((vp->flags & VIMPORT) && (flag_off == ~VEXPORT)) {
15520 vp->flags &= ~VIMPORT;
15521 p = getenv(name);
15522 } else
15523#endif
15515 continue; 15524 continue;
15516 } 15525 }
15517 } 15526 }