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>
diff --git a/shell/hush.c b/shell/hush.c
index c4b1248..4c8814a 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -2397,6 +2397,12 @@
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 @@
}
#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 @@
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 @@
* TERM=dumb
* OPTERR=1
* OPTIND=1
- * IFS=$' \t\n'
* PS4='+ '
*/
-#endif
#if ENABLE_HUSH_LINENO_VAR
if (ENABLE_HUSH_LINENO_VAR) {