From 477c6890b0e9e934c5dbccb3f335da0f175f1a8f Mon Sep 17 00:00:00 2001 From: Philippe Altherr Date: Sun, 26 Oct 2025 13:39:33 -0700 Subject: 53732: avoid tail-call exec in always block --- ChangeLog | 4 ++++ Src/loop.c | 2 +- Test/A01grammar.ztst | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b64579ab1..ab940073b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2025-10-26 Bart Schaefer + + * Philippe: 53732: avoid tail-call exec in always block + 2025-10-24 Oliver Kiddle * 54002: Src/parse.c: silence compiler warning for static function diff --git a/Src/loop.c b/Src/loop.c index 979285abc..ba01b1da5 100644 --- a/Src/loop.c +++ b/Src/loop.c @@ -774,7 +774,7 @@ exectry(Estate state, int do_exec) contflag = 0; state->pc = always; - execlist(state, 1, do_exec); + execlist(state, 1, 0); if (try_errflag) errflag |= ERRFLAG_ERROR; diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst index 660602caf..a65dc57f1 100644 --- a/Test/A01grammar.ztst +++ b/Test/A01grammar.ztst @@ -720,6 +720,12 @@ >always 1 >try 2 + () { { return 2 } always { return 3 } } +2:Exit status of always block is ignored + + () { ( { return 2 } always { ( return 3 ) } ) } +2:Regression test for exit status of always block is ignored also in tailcalls + ( mywrap() { echo BEGIN; true; echo END } mytest() { { exit 3 } always { mywrap }; print Exited before this } -- cgit v1.2.3-70-g09d2