klibc-bot for Herbert Xu
2020-Mar-28 21:48 UTC
[klibc] [klibc:update-dash] dash: [BUILTIN] Allow return in loop conditional to set exit status
Commit-ID: 020270d27f71a91afa9238152fe55da2dbcb5800 Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=020270d27f71a91afa9238152fe55da2dbcb5800 Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Mon, 6 Oct 2014 21:22:43 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:54 +0000 [klibc] dash: [BUILTIN] Allow return in loop conditional to set exit status [ dash commit f14b4626eb5c1c2fda137e7d1520c5f1cb7e85c4 ] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=332954 When return is used in a loop conditional the exit status will be lost because we always set the exit status at the end of the loop to that of the last command executed in the body. This is counterintuitive and contrary to what most other shells do. This patch fixes this by always preserving the exit status of return when it is used in a loop conditional. The patch was originally written by Gerrit Pape <pape at smarden.org>. Reported-by: Stephane Chazelas <stephane_chazelas at yahoo.fr> Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/dash/eval.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr/dash/eval.c b/usr/dash/eval.c index 6cc92c19..bb9fc260 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -387,8 +387,9 @@ evalloop(union node *n, int flags) status = exitstatus; skip = skiploop(); } while (!(skip & ~SKIPCONT)); + if (skip != SKIPFUNC) + exitstatus = status; loopnest--; - exitstatus = status; }
Possibly Parallel Threads
- [klibc:update-dash] [BUILTIN] Allow return in loop conditional to set exit status
- [klibc:update-dash] eval: Return status in eval functions
- [klibc:update-dash] dash: eval: Return status in eval functions
- [klibc:update-dash] dash: [EVAL] Move common skipcount logic into skiploop
- [klibc:update-dash] [EVAL] Move common skipcount logic into skiploop