diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2010-11-28 20:22:00 +0800 |
---|---|---|
committer | maximilian attems <max@stro.at> | 2011-06-03 18:44:13 +0200 |
commit | 5ab344012d0df691e7497dd5fd7108e6ce238596 (patch) | |
tree | c2459db8783a79451cfa7e7a12c6f95e668713a2 | |
parent | 69fa392db095e9b0663150b45f4a869ae4d3a8d1 (diff) | |
download | klibc-5ab344012d0df691e7497dd5fd7108e6ce238596.tar.gz |
[klibc] [ERROR] Allow the originator of EXERROR to set the exit
status
Some errors have exit status values specified by POSIX and it is
therefore desirable to be able to set the exit status at the EXERROR
source rather than in main.c.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: maximilian attems <max@stro.at>
-rw-r--r-- | usr/dash/error.c | 2 | ||||
-rw-r--r-- | usr/dash/eval.c | 6 | ||||
-rw-r--r-- | usr/dash/main.c | 2 |
3 files changed, 6 insertions, 4 deletions
diff --git a/usr/dash/error.c b/usr/dash/error.c index e304d3d44ed60..f1a358db04724 100644 --- a/usr/dash/error.c +++ b/usr/dash/error.c @@ -163,6 +163,8 @@ sh_error(const char *msg, ...) { va_list ap; + exitstatus = 2; + va_start(ap, msg); exverror(EXERROR, msg, ap); /* NOTREACHED */ diff --git a/usr/dash/eval.c b/usr/dash/eval.c index ae4719a986c5a..cd81ce06d4505 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -823,11 +823,13 @@ evalcommand(union node *cmd, int flags) } if (status) { +bail: + exitstatus = status; + /* We have a redirection error. */ if (spclbltin > 0) exraise(EXERROR); -bail: - exitstatus = status; + goto out; } diff --git a/usr/dash/main.c b/usr/dash/main.c index 2bff9561a90b6..1735c672fd483 100644 --- a/usr/dash/main.c +++ b/usr/dash/main.c @@ -113,8 +113,6 @@ main(int argc, char **argv) reset(); e = exception; - if (e == EXERROR) - exitstatus = 2; s = state; if (e == EXEXIT || s == 0 || iflag == 0 || shlvl) |