diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2014-04-15 11:43:29 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2014-04-15 11:43:29 +0200 |
commit | 3fa97af7ccc75264fb237f279f253eddf0ba4da1 (patch) | |
tree | d9897c308b55ecaf08b3f6da191b4a1d03e387a8 /shell/hush.c | |
parent | ad16741ccd8a8587644d88fb8fdfc41ada1928a6 (diff) | |
download | busybox-w32-3fa97af7ccc75264fb237f279f253eddf0ba4da1.tar.gz busybox-w32-3fa97af7ccc75264fb237f279f253eddf0ba4da1.tar.bz2 busybox-w32-3fa97af7ccc75264fb237f279f253eddf0ba4da1.zip |
ash,hush: set $HOSTNAME is bash compat. Closes 7028
function old new delta
hush_main 1056 1128 +72
ash_main 1442 1487 +45
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/shell/hush.c b/shell/hush.c index 7b0ea8b0c..e1d0ece29 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -91,6 +91,7 @@ | |||
91 | #if ENABLE_HUSH_CASE | 91 | #if ENABLE_HUSH_CASE |
92 | # include <fnmatch.h> | 92 | # include <fnmatch.h> |
93 | #endif | 93 | #endif |
94 | #include <sys/utsname.h> /* for setting $HOSTNAME */ | ||
94 | 95 | ||
95 | #include "busybox.h" /* for APPLET_IS_NOFORK/NOEXEC */ | 96 | #include "busybox.h" /* for APPLET_IS_NOFORK/NOEXEC */ |
96 | #include "unicode.h" | 97 | #include "unicode.h" |
@@ -7786,6 +7787,14 @@ int hush_main(int argc, char **argv) | |||
7786 | 7787 | ||
7787 | /* Export PWD */ | 7788 | /* Export PWD */ |
7788 | set_pwd_var(/*exp:*/ 1); | 7789 | set_pwd_var(/*exp:*/ 1); |
7790 | |||
7791 | #if ENABLE_HUSH_BASH_COMPAT | ||
7792 | /* Set (but not export) HOSTNAME unless already set */ | ||
7793 | if (!get_local_var_value("HOSTNAME")) { | ||
7794 | struct utsname uts; | ||
7795 | uname(&uts); | ||
7796 | set_local_var_from_halves("HOSTNAME", uts.nodename); | ||
7797 | } | ||
7789 | /* bash also exports SHLVL and _, | 7798 | /* bash also exports SHLVL and _, |
7790 | * and sets (but doesn't export) the following variables: | 7799 | * and sets (but doesn't export) the following variables: |
7791 | * BASH=/bin/bash | 7800 | * BASH=/bin/bash |
@@ -7794,7 +7803,6 @@ int hush_main(int argc, char **argv) | |||
7794 | * HOSTTYPE=i386 | 7803 | * HOSTTYPE=i386 |
7795 | * MACHTYPE=i386-pc-linux-gnu | 7804 | * MACHTYPE=i386-pc-linux-gnu |
7796 | * OSTYPE=linux-gnu | 7805 | * OSTYPE=linux-gnu |
7797 | * HOSTNAME=<xxxxxxxxxx> | ||
7798 | * PPID=<NNNNN> - we also do it elsewhere | 7806 | * PPID=<NNNNN> - we also do it elsewhere |
7799 | * EUID=<NNNNN> | 7807 | * EUID=<NNNNN> |
7800 | * UID=<NNNNN> | 7808 | * UID=<NNNNN> |
@@ -7822,6 +7830,7 @@ int hush_main(int argc, char **argv) | |||
7822 | * PS2='> ' | 7830 | * PS2='> ' |
7823 | * PS4='+ ' | 7831 | * PS4='+ ' |
7824 | */ | 7832 | */ |
7833 | #endif | ||
7825 | 7834 | ||
7826 | #if ENABLE_FEATURE_EDITING | 7835 | #if ENABLE_FEATURE_EDITING |
7827 | G.line_input_state = new_line_input_t(FOR_SHELL); | 7836 | G.line_input_state = new_line_input_t(FOR_SHELL); |