summaryrefslogtreecommitdiff
path: root/shell/ash_test/ash-misc
diff options
context:
space:
mode:
authorRon Yorston2017-01-03 11:18:23 +0100
committerDenys Vlasenko2017-01-03 11:18:23 +0100
commitea7d2f6ec0596789fc5b2e3fca3b7a602bfa2c26 (patch)
tree80bf9f7fae0b7dc5c8cd0047129ce792ceb37ec9 /shell/ash_test/ash-misc
parentbddbeb82bfeac8d4795ab995eae09109c048e9df (diff)
downloadbusybox-ea7d2f6ec0596789fc5b2e3fca3b7a602bfa2c26.zip
busybox-ea7d2f6ec0596789fc5b2e3fca3b7a602bfa2c26.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_test/ash-misc')
-rw-r--r--shell/ash_test/ash-misc/exitcode2.right4
-rwxr-xr-xshell/ash_test/ash-misc/exitcode2.tests12
2 files changed, 16 insertions, 0 deletions
diff --git a/shell/ash_test/ash-misc/exitcode2.right b/shell/ash_test/ash-misc/exitcode2.right
new file mode 100644
index 0000000..f7cb983
--- /dev/null
+++ b/shell/ash_test/ash-misc/exitcode2.right
@@ -0,0 +1,4 @@
+./test.sh: line 1: syntax error: unexpected ")"
+Done:2
+./exitcode2.tests: line 11: can't open does_not_exist: no such file
+Done:1
diff --git a/shell/ash_test/ash-misc/exitcode2.tests b/shell/ash_test/ash-misc/exitcode2.tests
new file mode 100755
index 0000000..79a6ebd
--- /dev/null
+++ b/shell/ash_test/ash-misc/exitcode2.tests
@@ -0,0 +1,12 @@
+# syntax error should return status 2
+cat >test.sh <<EOF
+)
+EOF
+chmod +x test.sh
+$THIS_SH ./test.sh
+echo Done:$?
+rm -f test.sh
+
+# redirection error with special builtin should return status 1
+(eval cat <does_not_exist)
+echo Done:$?