aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2022-05-08 11:05:30 +0100
committerRon Yorston <rmy@pobox.com>2022-05-08 11:05:30 +0100
commit3194a475deb5e3e9e7aef680d9bf5fb0a63d551a (patch)
tree3f67439af8aca8b754d0a1c8146d5118b6bd83ae /libbb
parentdc6dbbd9601aeaa9f715b2ea8ec128e6b7846eb9 (diff)
downloadbusybox-w32-3194a475deb5e3e9e7aef680d9bf5fb0a63d551a.tar.gz
busybox-w32-3194a475deb5e3e9e7aef680d9bf5fb0a63d551a.tar.bz2
busybox-w32-3194a475deb5e3e9e7aef680d9bf5fb0a63d551a.zip
ash: export certain variables to the environment immediately
The environment variables BB_OVERRIDE_APPLETS, BB_SKIP_ANSI_EMULATION and BB_SYSTEMROOT affect of the behaviour of the shell itself. Setting them as shell variables is insufficient for them to affect the current shell. When these three variables are exported from the shell they are now placed in the environment immediately. Conversely, when they're unset or unexported they're removed from the environment.
Diffstat (limited to 'libbb')
-rw-r--r--libbb/appletlib.c2
-rw-r--r--libbb/messages.c12
2 files changed, 12 insertions, 2 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 8d58ce2ea..9e415610d 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -268,7 +268,7 @@ int FAST_FUNC is_applet_preferred(const char *name)
268 const char *var, *s; 268 const char *var, *s;
269 size_t len; 269 size_t len;
270 270
271 var = getenv("BB_OVERRIDE_APPLETS"); 271 var = getenv(BB_OVERRIDE_APPLETS);
272 if (var && *var) { 272 if (var && *var) {
273 /* '-' overrides all applets */ 273 /* '-' overrides all applets */
274 if (var[0] == '-' && var[1] == '\0') 274 if (var[0] == '-' && var[1] == '\0')
diff --git a/libbb/messages.c b/libbb/messages.c
index 04863855a..e35bf8c6b 100644
--- a/libbb/messages.c
+++ b/libbb/messages.c
@@ -30,7 +30,17 @@ const char bb_hexdigits_upcase[] ALIGN1 = "0123456789ABCDEF";
30#if !ENABLE_PLATFORM_MINGW32 30#if !ENABLE_PLATFORM_MINGW32
31const char bb_busybox_exec_path[] ALIGN1 = CONFIG_BUSYBOX_EXEC_PATH; 31const char bb_busybox_exec_path[] ALIGN1 = CONFIG_BUSYBOX_EXEC_PATH;
32#else 32#else
33const char bb_skip_ansi_emulation[] ALIGN1 = "BB_SKIP_ANSI_EMULATION"; 33/* Some special shell variables are placed in the environment immediately
34 * when they're exported.
35 *
36 * BB_GLOBBING and BB_UMASK are excluded because users shouln't be
37 * messing with them; BB_ALT_BUFFER and BB_FIX_BACKSLASH are excluded
38 * because they only affect particular applets, not the shell itself.
39 */
40const char bbvar[] ALIGN1 =
41 "BB_OVERRIDE_APPLETS\0" \
42 "BB_SKIP_ANSI_EMULATION\0" \
43 "BB_SYSTEMROOT\0";
34#endif 44#endif
35const char bb_default_login_shell[] ALIGN1 = LIBBB_DEFAULT_LOGIN_SHELL; 45const char bb_default_login_shell[] ALIGN1 = LIBBB_DEFAULT_LOGIN_SHELL;
36/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, 46/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin,