]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
fix to trap execution to avoid the shell believing it's still executing the handler...
authorChet Ramey <chet.ramey@case.edu>
Tue, 9 Aug 2022 14:43:00 +0000 (10:43 -0400)
committerChet Ramey <chet.ramey@case.edu>
Tue, 9 Aug 2022 14:43:00 +0000 (10:43 -0400)
CHANGES
CHANGES-5.2
CWRU/CWRU.chlog
NEWS
NEWS-5.2
configure
configure.ac
trap.c

diff --git a/CHANGES b/CHANGES
index ef6806433881198ffbd8c3fc97746084f4e41d53..46386fe3403fc3e9f062c3108c1aa213fd596e98 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -444,7 +444,7 @@ z. The new `--enable-translatable-strings' option to `configure' allows $"..."
    support to be compiled in or out.
 
 aa. The new `globskipdots' shell option forces pathname expansion never to
-    return `.' or `..' unless explicitly matched.
+    return `.' or `..' unless explicitly matched. It is enabled by default.
 
 bb. Array references using `@' and `*' that are the value of nameref variables
     (declare -n ref='v[@]' ; echo $ref) no longer cause the shell to exit if
index 262cd6f50e6072c20946203e5e555d045dae286f..3a1239b3312b5569fdde331d9c22216a5fece75e 100644 (file)
@@ -444,7 +444,7 @@ z. The new `--enable-translatable-strings' option to `configure' allows $"..."
    support to be compiled in or out.
 
 aa. The new `globskipdots' shell option forces pathname expansion never to
-    return `.' or `..' unless explicitly matched.
+    return `.' or `..' unless explicitly matched. It is enabled by default.
 
 bb. Array references using `@' and `*' that are the value of nameref variables
     (declare -n ref='v[@]' ; echo $ref) no longer cause the shell to exit if
index 83446766ef339c4e3a91c41f96d9aa5ed0b034b9..43cd3de2f1247c28b937ac88e03c55bb85a67e18 100644 (file)
@@ -3845,3 +3845,16 @@ parse.y
          so parse errors can be caught before forking a child for command
          substitution, as part of word expansion, but after extglob may have
          been set by command execution (e.g., in a shell function)
+
+                                   8/5
+                                   ---
+[bump version to bash-5.2-rc3]
+
+                                   8/6
+                                   ---
+trap.c
+       - run_pending_traps: move code from evalstring() so we call
+         parse_and_execute() directly and handle any `return' invocations so
+         we can restore the value of running_trap. Otherwise, if we longjmp
+         past this function, we will think we're running a trap after we
+         finish. Prompted by post from Koichi Murase <myoga.murase@gmail.com>
diff --git a/NEWS b/NEWS
index 31bb6616d389d4d2493f51f93da50b18a1835fb2..e5ada2f57333160069098f3b02ca1a51ce25fb1a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -94,7 +94,7 @@ z. The new `--enable-translatable-strings' option to `configure' allows $"..."
    support to be compiled in or out.
 
 aa. The new `globskipdots' shell option forces pathname expansion never to
-    return `.' or `..' unless explicitly matched.
+    return `.' or `..' unless explicitly matched. It is enabled by default.
 
 bb. Array references using `@' and `*' that are the value of nameref variables
     (declare -n ref='v[@]' ; echo $ref) no longer cause the shell to exit if
index e685e0afc73851748e9db4d27fa0c80420397694..f2e7af3da5f0e6cf4f518769b9a55ea175462bce 100644 (file)
--- a/NEWS-5.2
+++ b/NEWS-5.2
@@ -94,7 +94,7 @@ z. The new `--enable-translatable-strings' option to `configure' allows $"..."
    support to be compiled in or out.
 
 aa. The new `globskipdots' shell option forces pathname expansion never to
-    return `.' or `..' unless explicitly matched.
+    return `.' or `..' unless explicitly matched. It is enabled by default.
 
 bb. Array references using `@' and `*' that are the value of nameref variables
     (declare -n ref='v[@]' ; echo $ref) no longer cause the shell to exit if
index 994f727568d794db2dfa804ffed7effc5a24d54f..5da013c181e6d4d0cfde07a6b0b2516127678d68 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,7 +1,7 @@
 #! /bin/sh
-# From configure.ac for Bash 5.2, version 5.043.
+# From configure.ac for Bash 5.2, version 5.044.
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.71 for bash 5.2-rc2.
+# Generated by GNU Autoconf 2.71 for bash 5.2-rc3.
 #
 # Report bugs to <bug-bash@gnu.org>.
 #
@@ -612,8 +612,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='bash'
 PACKAGE_TARNAME='bash'
-PACKAGE_VERSION='5.2-rc2'
-PACKAGE_STRING='bash 5.2-rc2'
+PACKAGE_VERSION='5.2-rc3'
+PACKAGE_STRING='bash 5.2-rc3'
 PACKAGE_BUGREPORT='bug-bash@gnu.org'
 PACKAGE_URL=''
 
@@ -1467,7 +1467,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures bash 5.2-rc2 to adapt to many kinds of systems.
+\`configure' configures bash 5.2-rc3 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1533,7 +1533,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of bash 5.2-rc2:";;
+     short | recursive ) echo "Configuration of bash 5.2-rc3:";;
    esac
   cat <<\_ACEOF
 
@@ -1740,7 +1740,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-bash configure 5.2-rc2
+bash configure 5.2-rc3
 generated by GNU Autoconf 2.71
 
 Copyright (C) 2021 Free Software Foundation, Inc.
@@ -2397,7 +2397,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by bash $as_me 5.2-rc2, which was
+It was created by bash $as_me 5.2-rc3, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   $ $0$ac_configure_args_raw
@@ -3176,7 +3176,7 @@ ac_config_headers="$ac_config_headers config.h"
 
 
 BASHVERS=5.2
-RELSTATUS=rc2
+RELSTATUS=rc3
 
 case "$RELSTATUS" in
 alp*|bet*|dev*|rc*|releng*|maint*)     DEBUG='-DDEBUG' MALLOC_DEBUG='-DMALLOC_DEBUG' ;;
@@ -22369,7 +22369,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by bash $as_me 5.2-rc2, which was
+This file was extended by bash $as_me 5.2-rc3, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -22437,7 +22437,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config='$ac_cs_config_escaped'
 ac_cs_version="\\
-bash config.status 5.2-rc2
+bash config.status 5.2-rc3
 configured by $0, generated by GNU Autoconf 2.71,
   with options \\"\$ac_cs_config\\"
 
index 034b3e23fb6d704d79e0cb2db4c364b12c3a467a..c5f136fe60d99948ff800ca73486d54d5159eaaf 100644 (file)
@@ -21,10 +21,10 @@ dnl Process this file with autoconf to produce a configure script.
 #   You should have received a copy of the GNU General Public License
 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-AC_REVISION([for Bash 5.2, version 5.043])dnl
+AC_REVISION([for Bash 5.2, version 5.044])dnl
 
 define(bashvers, 5.2)
-define(relstatus, rc2)
+define(relstatus, rc3)
 
 AC_INIT([bash], bashvers-relstatus, [bug-bash@gnu.org])
 
diff --git a/trap.c b/trap.c
index 8c0547559163ef06412dee37b6d9e45f57276628..dd0245e6dd881fbb33afe1d5ce11448034450188 100644 (file)
--- a/trap.c
+++ b/trap.c
@@ -297,11 +297,13 @@ void
 run_pending_traps ()
 {
   register int sig;
-  int old_exit_value, x;
-  int old_running;
+  int x;
+  volatile int old_exit_value, old_running;
   WORD_LIST *save_subst_varlist;
   HASH_TABLE *save_tempenv;
   sh_parser_state_t pstate;
+  volatile int save_return_catch_flag, function_code;
+  procenv_t save_return_catch;
 #if defined (ARRAY_VARS)
   ARRAY *ps;
 #endif
@@ -341,9 +343,7 @@ run_pending_traps ()
         while (pending_traps[sig]--) instead of the if statement. */
       if (pending_traps[sig])
        {
-         if (running_trap == sig+1)
-           /*continue*/;
-
+         /* XXX - set last_command_exit_value = trap_saved_exit_value here? */
          running_trap = sig + 1;
 
          if (sig == SIGINT)
@@ -419,7 +419,6 @@ run_pending_traps ()
            }
          else
            {
-             /* XXX - should we use save_parser_state/restore_parser_state? */
              save_parser_state (&pstate);
              save_subst_varlist = subst_assign_varlist;
              subst_assign_varlist = 0;
@@ -432,7 +431,23 @@ run_pending_traps ()
              /* XXX - set pending_traps[sig] = 0 here? */
              pending_traps[sig] = 0;
              evalnest++;
-             evalstring (savestring (trap_list[sig]), "trap", SEVAL_NONINT|SEVAL_NOHIST|SEVAL_RESETLINE);
+
+             function_code = 0;
+             save_return_catch_flag = return_catch_flag;
+             if (return_catch_flag)
+               {
+                 COPY_PROCENV (return_catch, save_return_catch);
+                 function_code = setjmp_nosigs (return_catch);
+               }
+
+             if (function_code == 0)
+               x = parse_and_execute (savestring (trap_list[sig]), "trap", SEVAL_NONINT|SEVAL_NOHIST|SEVAL_RESETLINE);
+             else
+               {
+                 parse_and_execute_cleanup (sig + 1);  /* XXX - could use -1 */
+                 x = return_catch_value;
+               }
+
              evalnest--;
 #if defined (JOB_CONTROL)
              restore_pipeline (1);
@@ -441,6 +456,19 @@ run_pending_traps ()
              subst_assign_varlist = save_subst_varlist;
              restore_parser_state (&pstate);
              temporary_env = save_tempenv;
+
+             if (save_return_catch_flag)
+               {
+                 return_catch_flag = save_return_catch_flag;
+                 return_catch_value = x;
+                 COPY_PROCENV (save_return_catch, return_catch);
+                 if (function_code)
+                   {
+                     running_trap = old_running;               /* XXX */
+                     /* caller will set last_command_exit_value */
+                     sh_longjmp (return_catch, 1);
+                   }
+               }
            }
 
          pending_traps[sig] = 0;       /* XXX - move before evalstring? */