From da30b4b787695fbf77e5d941ff350a66ca572bcb Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Mon, 6 Oct 2014 10:39:47 +0800 Subject: [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 --- src/main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index f79ad7d..29a258d 100644 --- a/src/main.c +++ b/src/main.c @@ -339,8 +339,15 @@ exitcmd(int argc, char **argv) { if (stoppedjobs()) return 0; - if (argc > 1) - exitstatus = number(argv[1]); + + if (argc > 1) { + int status = number(argv[1]); + + exitstatus = status; + if (savestatus >= 0) + savestatus = status; + } + exraise(EXEXIT); /* NOTREACHED */ } -- cgit 1.4.1