summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2018-05-19 02:39:38 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2018-05-28 17:12:22 +0800
commitd17dacd0f0499a8c77d810e211e8ff96b8898c48 (patch)
treedcbcc46daeee8f85324304539012bf6396f0ee66 /src
parentexec: Return 126 on most errors in shellexec (diff)
downloaddash-d17dacd0f0499a8c77d810e211e8ff96b8898c48.tar.gz
dash-d17dacd0f0499a8c77d810e211e8ff96b8898c48.zip
main: Only set savestatus in exitcmd
Currently exitcmd sets exitstatus and then savestatus if the latter
was previously set.  In fact, as exitcmd always raises an exception
and will either end up in the setjmp call in main() or exitshell(),
where exitstatus is always replaced by savestatus if set, we only
need to set savestatus.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'src')
-rw-r--r--src/main.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/main.c b/src/main.c
index fcd3e7d..9f03717 100644
--- a/src/main.c
+++ b/src/main.c
@@ -339,13 +339,8 @@ exitcmd(int argc, char **argv)
 	if (stoppedjobs())
 		return 0;
 
-	if (argc > 1) {
-		int status = number(argv[1]);
-
-		exitstatus = status;
-		if (savestatus >= 0)
-			savestatus = status;
-	}
+	if (argc > 1)
+		savestatus = number(argv[1]);
 
 	exraise(EXEXIT);
 	/* NOTREACHED */