klibc-bot for Herbert Xu
2020-Mar-28 21:49 UTC
[klibc] [klibc:update-dash] dash: main: Only set savestatus in exitcmd
Commit-ID: bb0a62dfa61fec6497f1409c3cdfe8ceec94f1fa Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=bb0a62dfa61fec6497f1409c3cdfe8ceec94f1fa Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Sat, 19 May 2018 02:39:38 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:55 +0000 [klibc] dash: main: Only set savestatus in exitcmd [ dash commit d17dacd0f0499a8c77d810e211e8ff96b8898c48 ] 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 at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/dash/main.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/usr/dash/main.c b/usr/dash/main.c index fcd3e7d2..9f037173 100644 --- a/usr/dash/main.c +++ b/usr/dash/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 */
Reasonably Related Threads
- [klibc:update-dash] [BUILTIN] Exit without arguments in a trap should use status outside traps
- [klibc:update-dash] dash: [BUILTIN] Exit without arguments in a trap should use status outside traps
- [klibc:update-dash] dash: eval: Only restore exit status on exit/return
- [klibc:update-dash] eval: Return status in eval functions
- [klibc:update-dash] dash: eval: Return status in eval functions