[git commit] hush: set IFS to default on startup

Denys Vlasenko vda.linux at googlemail.com
Sun Aug 5 16:11:15 UTC 2018


commit: https://git.busybox.net/busybox/commit/?id=fd6f295a98956b7f495ba09a56528ef9e0d51398
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
hush_main                                           1095    1110     +15

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/hush.c | 21 ++++++++++-----------
 1 file 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) {


More information about the busybox-cvs mailing list