aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2014-04-15 11:43:29 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2014-04-15 11:43:29 +0200
commit3fa97af7ccc75264fb237f279f253eddf0ba4da1 (patch)
treed9897c308b55ecaf08b3f6da191b4a1d03e387a8 /shell/ash.c
parentad16741ccd8a8587644d88fb8fdfc41ada1928a6 (diff)
downloadbusybox-3fa97af7ccc75264fb237f279f253eddf0ba4da1.tar.gz
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/ash.c')
-rw-r--r--shell/ash.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 7a097c814..cabeb40c5 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -41,6 +41,7 @@
#include <setjmp.h>
#include <fnmatch.h>
#include <sys/times.h>
+#include <sys/utsname.h> /* for setting $HOSTNAME */
#include "busybox.h" /* for applet_names */
#include "unicode.h"
@@ -13018,6 +13019,11 @@ init(void)
#if ENABLE_ASH_BASH_COMPAT
p = lookupvar("SHLVL");
setvar("SHLVL", utoa((p ? atoi(p) : 0) + 1), VEXPORT);
+ if (!lookupvar("HOSTNAME")) {
+ struct utsname uts;
+ uname(&uts);
+ setvar2("HOSTNAME", uts.nodename);
+ }
#endif
p = lookupvar("PWD");
if (p) {