diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2014-10-06 10:39:47 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-10-06 10:39:47 +0800 |
commit | da30b4b787695fbf77e5d941ff350a66ca572bcb (patch) | |
tree | 42950a7661b842fe4279bf5c28684def3c8c8fd8 /src/eval.c | |
parent | [EVAL] Do not clobber exitstatus in evalcommand (diff) | |
download | dash-da30b4b787695fbf77e5d941ff350a66ca572bcb.tar.gz dash-da30b4b787695fbf77e5d941ff350a66ca572bcb.zip |
[BUILTIN] Exit without arguments in a trap should use status outside traps
POSIX now requires that exit without arguments in a trap should return the last command status prior to executing traps. This patch implements this behaviour. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r-- | src/eval.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c index 3f4d957..51a900d 100644 --- a/src/eval.c +++ b/src/eval.c @@ -74,6 +74,7 @@ static int funcline; /* starting line number of current function, or 0 if not i char *commandname; int exitstatus; /* exit status of last command */ int back_exitstatus; /* exit status of backquoted command */ +int savestatus = -1; /* exit status of last command outside traps */ #if !defined(__alpha__) || (defined(__GNUC__) && __GNUC__ >= 3) @@ -114,6 +115,10 @@ INCLUDE "eval.h" RESET { evalskip = 0; loopnest = 0; + if (savestatus >= 0) { + exitstatus = savestatus; + savestatus = -1; + } } #endif |