bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

shebang-less script execution not resetting some options


From: Grisha Levit
Subject: shebang-less script execution not resetting some options
Date: Mon, 30 Sep 2019 17:39:48 -0400

A few of the recently-added shopt options aren't getting reset when
running a shebang-less script, this should fix it up:

--- a/builtins/shopt.def
+++ b/builtins/shopt.def
@@ -349,11 +349,16 @@ reset_shopt_options ()
   inherit_errexit = 0;
   interactive_comments = 1;
   lastpipe_opt = 0;
+  localvar_inherit = localvar_unset = 0;
   mail_warning = 0;
   glob_ignore_case = match_ignore_case = 0;
   print_shift_error = 0;
   source_uses_path = promptvars = 1;

+#if defined (ARRAY_VARS)
+  assoc_expand_once = 0;
+#endif
+
 #if defined (JOB_CONTROL)
   check_jobs_at_exit = 0;
 #endif
@@ -392,6 +397,9 @@ reset_shopt_options ()

 #if defined (PROGRAMMABLE_COMPLETION)
   prog_completion_enabled = 1;
+#   if defined (ALIAS)
+  progcomp_alias = 0;
+#   endif
 #endif

 #if defined (DEFAULT_ECHO_TO_XPG) || defined (STRICT_POSIX)


Maybe verifying this is something that can be added to the test suite?
Something like:

t1=$(mktemp) t2=$(mktemp)
chmod +x "$t1" "$t2"

echo "shopt" > "$t1"

echo "#!${THIS_SH}" > "$t2"
echo "shopt" >> "$t2"

for o in $(compgen -A shopt); do shopt -s $o; done
diff <("$t1") <("$t2")

for o in $(compgen -A shopt); do shopt -u $o; done
diff <("$t1") <("$t2")

rm "$t1" "$t2"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]