commit 41d203e21f94c1b8bfc457606ee633c22da3cf04
Author: Chet Ramey <chet.ramey@case.edu>
Date:   Wed Jun 12 09:29:51 2013 -0400

    commit bash-20130523 snapshot

diff --git a/trap.c b/trap.c
index 1e11d1f..da59b26 100644
--- a/trap.c
+++ b/trap.c
@@ -286,6 +286,9 @@ run_pending_traps ()
   if (catch_flag == 0)		/* simple optimization */
     return;
 
+  if (running_trap > 0)
+    return;			/* no recursive trap invocations */
+
   catch_flag = trapped_signal_received = 0;
 
   /* Preserve $? when running trap. */
@@ -304,6 +307,8 @@ run_pending_traps ()
 
 	  BLOCK_SIGNAL (sig, set, oset);
 
+	  running_trap = sig + 1;
+
 	  if (sig == SIGINT)
 	    {
 	      run_interrupt_trap ();
@@ -324,6 +329,7 @@ run_pending_traps ()
 	    {
 	      /* This can happen when run_pending_traps is called while
 		 running a SIGCHLD trap handler. */
+	      running_trap = 0;
 	      UNBLOCK_SIGNAL (oset);
 	      continue;					/* XXX */
 	    }
@@ -359,7 +365,14 @@ run_pending_traps ()
 	      save_subst_varlist = subst_assign_varlist;
 	      subst_assign_varlist = 0;
 
+#if defined (JOB_CONTROL)
+	      save_pipeline (1);	/* XXX only provides one save level */
+#endif
 	      evalstring (savestring (trap_list[sig]), "trap", SEVAL_NONINT|SEVAL_NOHIST|SEVAL_RESETLINE);
+#if defined (JOB_CONTROL)
+	      restore_pipeline (1);
+#endif
+
 	      restore_token_state (token_state);
 	      free (token_state);
 
@@ -367,6 +380,7 @@ run_pending_traps ()
 	    }
 
 	  pending_traps[sig] = 0;
+	  running_trap = 0;
 
 	  UNBLOCK_SIGNAL (oset);
 	}
