about summary refs log tree commit diff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorPeter Stephenson <p.stephenson@samsung.com>2018-07-09 11:06:07 +0100
committerPeter Stephenson <p.stephenson@samsung.com>2018-07-09 11:07:53 +0100
commit17178db1a4d8700c9e10862d0dd496f92c53f1cd (patch)
tree8081ecb3dcd951f77ed4b4bbbc63eddd76b51190 /Src/exec.c
parent8cb4fc00c29594aa6c497020b8ff5f7a4d4dd7ea (diff)
downloadzsh-17178db1a4d8700c9e10862d0dd496f92c53f1cd.tar.gz
zsh-17178db1a4d8700c9e10862d0dd496f92c53f1cd.tar.xz
zsh-17178db1a4d8700c9e10862d0dd496f92c53f1cd.zip
users/23531: Error exit/return fixes.
Fix regression with trap on left hand side of pipe.

Fix forced return from shell structure within nested function.

Fix tests exiting too early.

Add new test case.
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/Src/exec.c b/Src/exec.c
index d44527841..586402070 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2728,6 +2728,11 @@ execcmd_fork(Estate state, int how, int type, Wordcode varspc,
 
     if (sigtrapped[SIGINT] & ZSIG_IGNORED)
 	holdintr();
+    /*
+     * EXIT traps shouldn't be called even if we forked to run
+     * shell code as this isn't the main shell.
+     */
+    sigtrapped[SIGEXIT] = 0;
 #ifdef HAVE_NICE
     /* Check if we should run background jobs at a lower priority. */
     if ((how & Z_ASYNC) && isset(BGNICE))
@@ -5792,7 +5797,19 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
     undoshfunc:
 	--funcdepth;
 	if (retflag) {
+	    /*
+	     * This function is forced to return.
+	     */
 	    retflag = 0;
+	    /*
+	     * The calling function isn't necessarily forced to return,
+	     * but it should be made sensitive to ERR_EXIT and
+	     * ERR_RETURN as the assumptions we made at the end of
+	     * constructs within this function no longer apply.  If
+	     * there are cases where this is not true, they need adding
+	     * to C03traps.ztst.
+	     */
+	    this_noerrexit = 0;
 	    breaks = funcsave->breaks;
 	}
 	freearray(pparams);