diff options
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 7b0ea8b..e1d0ece 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -91,6 +91,7 @@ #if ENABLE_HUSH_CASE # include <fnmatch.h> #endif +#include <sys/utsname.h> /* for setting $HOSTNAME */ #include "busybox.h" /* for APPLET_IS_NOFORK/NOEXEC */ #include "unicode.h" @@ -7786,6 +7787,14 @@ int hush_main(int argc, char **argv) /* Export PWD */ set_pwd_var(/*exp:*/ 1); + +#if ENABLE_HUSH_BASH_COMPAT + /* Set (but not export) HOSTNAME unless already set */ + if (!get_local_var_value("HOSTNAME")) { + struct utsname uts; + uname(&uts); + set_local_var_from_halves("HOSTNAME", uts.nodename); + } /* bash also exports SHLVL and _, * and sets (but doesn't export) the following variables: * BASH=/bin/bash @@ -7794,7 +7803,6 @@ int hush_main(int argc, char **argv) * HOSTTYPE=i386 * MACHTYPE=i386-pc-linux-gnu * OSTYPE=linux-gnu - * HOSTNAME=<xxxxxxxxxx> * PPID=<NNNNN> - we also do it elsewhere * EUID=<NNNNN> * UID=<NNNNN> @@ -7822,6 +7830,7 @@ int hush_main(int argc, char **argv) * PS2='> ' * PS4='+ ' */ +#endif #if ENABLE_FEATURE_EDITING G.line_input_state = new_line_input_t(FOR_SHELL); |