summaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorRon Yorston2017-01-03 11:18:23 +0100
committerDenys Vlasenko2017-01-10 16:55:51 +0100
commit568cabf98a11e2e594243a309a9ffd7729a2b213 (patch)
tree786f2620a7217e3c7238df0fe39b9be351d42ef1 /shell/ash.c
parente94d2c5f242c793db1d76a4c0a63740de8ae6899 (diff)
downloadbusybox-568cabf98a11e2e594243a309a9ffd7729a2b213.zip
busybox-568cabf98a11e2e594243a309a9ffd7729a2b213.tar.gz
ash: fix error code regression
The commit 'ash,hush: set exit code 127 in "sh /does/not/exist" case' only partly implemented the dash commit '[ERROR] Allow the originator of EXERROR to set the exit status'. This resulted in incorrect error codes for a syntax error: $ ) $ echo $? 0 or a redirection error for a special builtin: $ rm -f xxx $ eval cat <xxx $ echo $? 0 Signed-off-by: Ron Yorston <rmy@pobox.com> Reported-by: Martijn Dekker <martijn@inlv.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 430e42a..7c53946 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -1284,6 +1284,8 @@ ash_msg_and_raise_error(const char *msg, ...)
{
va_list ap;
+ exitstatus = 2;
+
va_start(ap, msg);
ash_vmsg_and_raise(EXERROR, msg, ap);
/* NOTREACHED */
@@ -9588,11 +9590,13 @@ evalcommand(union node *cmd, int flags)
}
if (status) {
+ bail:
+ exitstatus = status;
+
/* We have a redirection error. */
if (spclbltin > 0)
raise_exception(EXERROR);
- bail:
- exitstatus = status;
+
goto out;
}