From 40d0bdc2876f48d34d9c70162c3d0608f472ddec Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Mon, 8 Jun 2020 17:00:49 +0200 Subject: [PATCH] Fix regression in 'return' introduced by 98e0fc94 This fixes two regression test failures in tests/functions.sh. src/cmd/ksh93/bltins/cflow.c: b_exit(): - The exit status should of course only be cropped to 8 bits if b_exit() will actually exit, not if it returns from a function. (cherry picked from commit 2d1e7f87551159c942b16de2a98dc72697988d26) --- src/cmd/ksh93/bltins/cflow.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd/ksh93/bltins/cflow.c b/src/cmd/ksh93/bltins/cflow.c index fb2fccc6b..9396de789 100644 --- a/src/cmd/ksh93/bltins/cflow.c +++ b/src/cmd/ksh93/bltins/cflow.c @@ -70,7 +70,8 @@ done: /* return outside of function, dotscript and profile is exit */ if(shp->fn_depth==0 && shp->dot_depth==0 && !sh_isstate(SH_PROFILE)) pp->mode = SH_JMPEXIT; - sh_exit((shp->savexit = n) & SH_EXITMASK); + shp->savexit = n; + sh_exit((pp->mode == SH_JMPEXIT) ? (n & SH_EXITMASK) : n); return(1); }