Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15437

shebang-less script execution not resetting some options

From Grisha Levit <grishalevit@gmail.com>
Newsgroups gnu.bash.bug
Subject shebang-less script execution not resetting some options
Date 2019-09-30 17:39 -0400
Message-ID <mailman.537.1569879604.2651.bug-bash@gnu.org> (permalink)
References <CAMu=BrpjDvF9Rz=JFaGoxV5AwjRoq=aC1htaybVz_kPFsDinbA@mail.gmail.com>

Show all headers | View raw


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"

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

shebang-less script execution not resetting some options Grisha Levit <grishalevit@gmail.com> - 2019-09-30 17:39 -0400

csiph-web