From 3194a475deb5e3e9e7aef680d9bf5fb0a63d551a Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 8 May 2022 11:05:30 +0100 Subject: 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. --- libbb/messages.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'libbb/messages.c') 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"; #if !ENABLE_PLATFORM_MINGW32 const char bb_busybox_exec_path[] ALIGN1 = CONFIG_BUSYBOX_EXEC_PATH; #else -const char bb_skip_ansi_emulation[] ALIGN1 = "BB_SKIP_ANSI_EMULATION"; +/* Some special shell variables are placed in the environment immediately + * when they're exported. + * + * BB_GLOBBING and BB_UMASK are excluded because users shouln't be + * messing with them; BB_ALT_BUFFER and BB_FIX_BACKSLASH are excluded + * because they only affect particular applets, not the shell itself. + */ +const char bbvar[] ALIGN1 = + "BB_OVERRIDE_APPLETS\0" \ + "BB_SKIP_ANSI_EMULATION\0" \ + "BB_SYSTEMROOT\0"; #endif const char bb_default_login_shell[] ALIGN1 = LIBBB_DEFAULT_LOGIN_SHELL; /* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, -- cgit v1.2.3-55-g6feb