From d7110d8f01cae8c8d51c7abd0255f533cd8b8623 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 27 Apr 2017 18:56:18 +0100 Subject: 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. --- Src/exec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Src/exec.c') 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; -- cgit 1.4.1