about summary refs log tree commit diff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2017-04-27 18:56:18 +0100
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2017-04-27 18:56:18 +0100
commitd7110d8f01cae8c8d51c7abd0255f533cd8b8623 (patch)
tree238931229fcf7831c7ff5f41212f9626167fbb63 /Src/exec.c
parent48b0daf3d4972987873f1be00cc73d73734daf05 (diff)
downloadzsh-d7110d8f01cae8c8d51c7abd0255f533cd8b8623.tar.gz
zsh-d7110d8f01cae8c8d51c7abd0255f533cd8b8623.tar.xz
zsh-d7110d8f01cae8c8d51c7abd0255f533cd8b8623.zip
41012: Fix premature exit from nested function in EXIT trap.
Also add check so we don't delay an exit if we were already in
an EXIT trap for the main shell, as we should in that case leave
immediately.
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 978a32d20..e0fc54445 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -5688,8 +5688,11 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
      * the only likely case where we need that second test is
      * when we have an "always" block.  The endparamscope() has
      * already happened, hence the "+1" here.
+     *
+     * If we are in an exit trap, finish it first... we wouldn't set
+     * exit_pending if we were already in one.
      */
-    if (exit_pending && exit_level >= locallevel+1) {
+    if (exit_pending && exit_level >= locallevel+1 && !in_exit_trap) {
 	if (locallevel > forklevel) {
 	    /* Still functions to return: force them to do so. */
 	    retflag = 1;