diff options
author | Ron Yorston <rmy@pobox.com> | 2020-02-14 09:47:09 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2020-02-14 09:49:31 +0000 |
commit | 6c1047f6fdd50e447b7886facb479dcf04f6b860 (patch) | |
tree | 14ca168084bca8ca4ab58c1d02269457cef90440 | |
parent | f21cc9e93a6132d0471441569adfa86197f79ead (diff) | |
download | busybox-w32-6c1047f6fdd50e447b7886facb479dcf04f6b860.tar.gz busybox-w32-6c1047f6fdd50e447b7886facb479dcf04f6b860.tar.bz2 busybox-w32-6c1047f6fdd50e447b7886facb479dcf04f6b860.zip |
ash: code shrink
Commit 575581082 (ash: move code from setup_environment()) replaced
calls to xsetenv_if_unset() with explicit tests. I don't know why
because using xsetenv_if_unset() saves 48 bytes.
-rw-r--r-- | shell/ash.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/shell/ash.c b/shell/ash.c index 3a143229e..1b7fa9849 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -14850,6 +14850,14 @@ exitshell(void) | |||
14850 | /* NOTREACHED */ | 14850 | /* NOTREACHED */ |
14851 | } | 14851 | } |
14852 | 14852 | ||
14853 | #if ENABLE_PLATFORM_MINGW32 | ||
14854 | static void xsetenv_if_unset(const char *key, const char *value) | ||
14855 | { | ||
14856 | if (!getenv(key)) | ||
14857 | xsetenv(key, value); | ||
14858 | } | ||
14859 | #endif | ||
14860 | |||
14853 | /* Don't inline: conserve stack of caller from having our locals too */ | 14861 | /* Don't inline: conserve stack of caller from having our locals too */ |
14854 | static NOINLINE void | 14862 | static NOINLINE void |
14855 | init(void) | 14863 | init(void) |
@@ -14943,10 +14951,10 @@ init(void) | |||
14943 | /* Initialise some variables normally set at login, but | 14951 | /* Initialise some variables normally set at login, but |
14944 | * only if someone hasn't already set them. */ | 14952 | * only if someone hasn't already set them. */ |
14945 | pw = xgetpwuid(getuid()); | 14953 | pw = xgetpwuid(getuid()); |
14946 | if (!getenv("USER")) xsetenv("USER", pw->pw_name); | 14954 | xsetenv_if_unset("USER", pw->pw_name); |
14947 | if (!getenv("LOGNAME")) xsetenv("LOGNAME", pw->pw_name); | 14955 | xsetenv_if_unset("LOGNAME", pw->pw_name); |
14948 | if (!getenv("HOME")) xsetenv("HOME", pw->pw_dir); | 14956 | xsetenv_if_unset("HOME", pw->pw_dir); |
14949 | if (!getenv("SHELL")) xsetenv("SHELL", DEFAULT_SHELL); | 14957 | xsetenv_if_unset("SHELL", DEFAULT_SHELL); |
14950 | } | 14958 | } |
14951 | #endif | 14959 | #endif |
14952 | for (envp = environ; envp && *envp; envp++) { | 14960 | for (envp = environ; envp && *envp; envp++) { |