summaryrefslogtreecommitdiff
path: root/shell/hush_test
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/hush_test
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/hush_test')
-rw-r--r--shell/hush_test/hush-misc/exitcode2.right4
-rwxr-xr-xshell/hush_test/hush-misc/exitcode2.tests12
2 files changed, 16 insertions, 0 deletions
diff --git a/shell/hush_test/hush-misc/exitcode2.right b/shell/hush_test/hush-misc/exitcode2.right
new file mode 100644
index 0000000..0a57b9b
--- /dev/null
+++ b/shell/hush_test/hush-misc/exitcode2.right
@@ -0,0 +1,4 @@
+hush: syntax error: unexpected )
+Done:2
+hush: can't open 'does_not_exist': No such file or directory
+Done:1
diff --git a/shell/hush_test/hush-misc/exitcode2.tests b/shell/hush_test/hush-misc/exitcode2.tests
new file mode 100755
index 0000000..79a6ebd
--- /dev/null
+++ b/shell/hush_test/hush-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:$?