summaryrefslogtreecommitdiff
Diffstat
-rw-r--r--shell/ash.c8
-rw-r--r--shell/ash_test/ash-misc/exitcode2.right4
-rwxr-xr-xshell/ash_test/ash-misc/exitcode2.tests12
-rw-r--r--shell/hush_test/hush-misc/exitcode2.right4
-rwxr-xr-xshell/hush_test/hush-misc/exitcode2.tests12
5 files changed, 38 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;
}