aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-08-05 15:13:08 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-08-05 18:11:15 +0200
commitfd6f295a98956b7f495ba09a56528ef9e0d51398 (patch)
tree1c2f6de4e58b0b25ec43923c242d13f684146d2c
parente9dccab9f4bf3311ae50f19e39e7e499b25edca2 (diff)
downloadbusybox-fd6f295a98956b7f495ba09a56528ef9e0d51398.tar.gz
hush: set IFS to default on startup
function old new delta hush_main 1095 1110 +15 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/hush.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/shell/hush.c b/shell/hush.c
index c4b124825..4c8814a01 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -2397,6 +2397,12 @@ static int set_local_var(char *str, unsigned flags)
return 0;
}
+static void FAST_FUNC set_local_var_from_halves(const char *name, const char *val)
+{
+ char *var = xasprintf("%s=%s", name, val);
+ set_local_var(var, /*flag:*/ 0);
+}
+
/* Used at startup and after each cd */
static void set_pwd_var(unsigned flag)
{
@@ -2443,15 +2449,6 @@ static int unset_local_var(const char *name)
}
#endif
-#if BASH_HOSTNAME_VAR || ENABLE_FEATURE_SH_MATH || ENABLE_HUSH_READ || ENABLE_HUSH_GETOPTS \
- || (ENABLE_HUSH_INTERACTIVE && ENABLE_FEATURE_EDITING_FANCY_PROMPT)
-static void FAST_FUNC set_local_var_from_halves(const char *name, const char *val)
-{
- char *var = xasprintf("%s=%s", name, val);
- set_local_var(var, /*flag:*/ 0);
-}
-#endif
-
/*
* Helpers for "var1=val1 var2=val2 cmd" feature
@@ -9854,6 +9851,10 @@ int hush_main(int argc, char **argv)
uname(&uts);
set_local_var_from_halves("HOSTNAME", uts.nodename);
}
+#endif
+ /* IFS is not inherited from the parent environment */
+ set_local_var_from_halves("IFS", defifs);
+
/* bash also exports SHLVL and _,
* and sets (but doesn't export) the following variables:
* BASH=/bin/bash
@@ -9884,10 +9885,8 @@ int hush_main(int argc, char **argv)
* TERM=dumb
* OPTERR=1
* OPTIND=1
- * IFS=$' \t\n'
* PS4='+ '
*/
-#endif
#if ENABLE_HUSH_LINENO_VAR
if (ENABLE_HUSH_LINENO_VAR) {