diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-05-20 14:27:09 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-05-20 14:27:09 +0200 |
commit | cddbb610cb0ea8d74668653aeaded710d2d13768 (patch) | |
tree | fea97f7c4fd0871543502d2fcefc189ee5d68288 /shell/hush_test | |
parent | 131ed3bcc9c9eabcb4bd6a063c24c6f9922f1491 (diff) | |
download | busybox-w32-cddbb610cb0ea8d74668653aeaded710d2d13768.tar.gz busybox-w32-cddbb610cb0ea8d74668653aeaded710d2d13768.tar.bz2 busybox-w32-cddbb610cb0ea8d74668653aeaded710d2d13768.zip |
hush: fix var=`exit 2` not setting $? to 2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush_test')
-rw-r--r-- | shell/hush_test/hush-psubst/falsetick.right | 27 | ||||
-rwxr-xr-x | shell/hush_test/hush-psubst/falsetick.tests | 22 |
2 files changed, 49 insertions, 0 deletions
diff --git a/shell/hush_test/hush-psubst/falsetick.right b/shell/hush_test/hush-psubst/falsetick.right new file mode 100644 index 000000000..0b98fb778 --- /dev/null +++ b/shell/hush_test/hush-psubst/falsetick.right | |||
@@ -0,0 +1,27 @@ | |||
1 | 0 | ||
2 | 0 | ||
3 | 0 | ||
4 | 0 | ||
5 | 2 | ||
6 | 2 | ||
7 | 2 | ||
8 | 2 | ||
9 | hush: can't open '/does/not/exist': No such file or directory | ||
10 | 1 | ||
11 | hush: can't open '/does/not/exist': No such file or directory | ||
12 | 1 | ||
13 | hush: can't open '/does/not/exist': No such file or directory | ||
14 | 1 | ||
15 | hush: can't open '/does/not/exist': No such file or directory | ||
16 | 1 | ||
17 | hush: can't open '/does/not/exist': No such file or directory | ||
18 | 1 | ||
19 | hush: can't open '/does/not/exist': No such file or directory | ||
20 | 1 | ||
21 | hush: can't open '/does/not/exist': No such file or directory | ||
22 | 1 | ||
23 | hush: can't open '/does/not/exist': No such file or directory | ||
24 | 1 | ||
25 | hush: can't open '/does/not/exist': No such file or directory | ||
26 | 1 | ||
27 | Done: a=b | ||
diff --git a/shell/hush_test/hush-psubst/falsetick.tests b/shell/hush_test/hush-psubst/falsetick.tests new file mode 100755 index 000000000..44d2eae8b --- /dev/null +++ b/shell/hush_test/hush-psubst/falsetick.tests | |||
@@ -0,0 +1,22 @@ | |||
1 | # Exitcode 0 (`` has no exitcode, but assignment has): | ||
2 | true; a=``; echo $? | ||
3 | false; a=``; echo $? | ||
4 | true; a=$(); echo $? | ||
5 | false; a=$(); echo $? | ||
6 | # Exitcode 2 (`cmd` expansion sets exitcode after assignment set it to 0): | ||
7 | true; a=`exit 2`; echo $? | ||
8 | false; a=`exit 2`; echo $? | ||
9 | true; a=$(exit 2); echo $? | ||
10 | false; a=$(exit 2); echo $? | ||
11 | # Exitcode 1 (redirect sets exitcode to 1 on error after them): | ||
12 | true; a=`` >/does/not/exist; echo $? | ||
13 | false; a=`` >/does/not/exist; echo $? | ||
14 | true; a=$() >/does/not/exist; echo $? | ||
15 | false; a=$() >/does/not/exist; echo $? | ||
16 | true; a=`exit 2` >/does/not/exist; echo $? | ||
17 | false; a=`exit 2` >/does/not/exist; echo $? | ||
18 | true; a=$(exit 2) >/does/not/exist; echo $? | ||
19 | false; a=$(exit 2) >/does/not/exist; echo $? | ||
20 | # ...and assignment still happens despite redirect error: | ||
21 | true; a=$(echo b) >/does/not/exist; echo $? | ||
22 | echo "Done: a=$a" | ||