diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-18 03:23:07 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-18 03:23:07 +0200 |
commit | f645e1573c5521c87b972400f9b4abc3636983d4 (patch) | |
tree | 89e95e92045f83a5dacf518c2c6a0dafc7185cd2 | |
parent | 5b2cc0aaee6985431d9bab1b49ceea7e1fa1d7af (diff) | |
download | busybox-w32-f645e1573c5521c87b972400f9b4abc3636983d4.tar.gz busybox-w32-f645e1573c5521c87b972400f9b4abc3636983d4.tar.bz2 busybox-w32-f645e1573c5521c87b972400f9b4abc3636983d4.zip |
hush: another testcase for "READONLY_VAR=VAL BLTIN ..."
Currently fails.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/hush_test/hush-vars/readonly0.right | 6 | ||||
-rwxr-xr-x | shell/hush_test/hush-vars/readonly0.tests | 16 | ||||
-rw-r--r-- | shell/hush_test/hush-vars/readonly2.right | 4 | ||||
-rwxr-xr-x | shell/hush_test/hush-vars/readonly2.tests | 6 |
4 files changed, 27 insertions, 5 deletions
diff --git a/shell/hush_test/hush-vars/readonly0.right b/shell/hush_test/hush-vars/readonly0.right index 07ca6e07f..8b750eb5f 100644 --- a/shell/hush_test/hush-vars/readonly0.right +++ b/shell/hush_test/hush-vars/readonly0.right | |||
@@ -1,14 +1,20 @@ | |||
1 | readonly a=A | 1 | readonly a=A |
2 | readonly b=B | 2 | readonly b=B |
3 | Ok:0 | 3 | Ok:0 |
4 | |||
4 | hush: a=A: readonly variable | 5 | hush: a=A: readonly variable |
5 | Fail:1 | 6 | Fail:1 |
6 | hush: a=A: readonly variable | 7 | hush: a=A: readonly variable |
7 | Fail:1 | 8 | Fail:1 |
9 | |||
8 | hush: a=Z: readonly variable | 10 | hush: a=Z: readonly variable |
9 | Fail:1 | 11 | Fail:1 |
12 | |||
10 | hush: a=Z: readonly variable | 13 | hush: a=Z: readonly variable |
11 | b=B | 14 | b=B |
12 | ^^^a is not exported | 15 | ^^^a is not exported |
16 | hush: a=Z: readonly variable | ||
17 | Visible:42 | ||
18 | |||
13 | hush: a: readonly variable | 19 | hush: a: readonly variable |
14 | Fail:1 | 20 | Fail:1 |
diff --git a/shell/hush_test/hush-vars/readonly0.tests b/shell/hush_test/hush-vars/readonly0.tests index 3ace9b767..0833ccf29 100755 --- a/shell/hush_test/hush-vars/readonly0.tests +++ b/shell/hush_test/hush-vars/readonly0.tests | |||
@@ -1,5 +1,5 @@ | |||
1 | unset a b | 1 | unset a b |
2 | 2 | # | |
3 | readonly a=A | 3 | readonly a=A |
4 | b=B | 4 | b=B |
5 | readonly b | 5 | readonly b |
@@ -12,6 +12,7 @@ export -n a b | |||
12 | echo Ok:$? | 12 | echo Ok:$? |
13 | env | grep -e^a= -e^b= # shows nothing | 13 | env | grep -e^a= -e^b= # shows nothing |
14 | 14 | ||
15 | echo | ||
15 | # these should all fail (despite the same value being assigned) | 16 | # these should all fail (despite the same value being assigned) |
16 | # bash does not abort even in non-interactive more (in script) | 17 | # bash does not abort even in non-interactive more (in script) |
17 | true; a=A | 18 | true; a=A |
@@ -19,18 +20,23 @@ echo Fail:$? | |||
19 | true; readonly a=A | 20 | true; readonly a=A |
20 | echo Fail:$? | 21 | echo Fail:$? |
21 | 22 | ||
23 | echo | ||
22 | # in bash, assignment in export fails, but export succeeds! :) | 24 | # in bash, assignment in export fails, but export succeeds! :) |
23 | # we don't mimic that! | 25 | # we don't mimic that! |
24 | true; export a=Z | 26 | true; export a=Z |
25 | echo Fail:$?; true | 27 | echo Fail:$? |
26 | #env | grep '^a=' | 28 | #env | grep '^a=' |
27 | #echo "^^^a is exported" | 29 | #echo "^^^a is exported" |
28 | export -n a # undo that bashism, if it happens | 30 | export -n a # undo that bashism, if it happens |
29 | 31 | ||
32 | echo | ||
30 | export b | 33 | export b |
31 | # this fails to both set and export a: | 34 | # this fails to both set and export a: |
32 | a=Z env | grep '^[ab]=' # command still runs | 35 | a=Z env | grep '^[ab]=' |
33 | echo "^^^a is not exported" | 36 | echo "^^^a is not exported" |
37 | # but external command does get executed, and $? is not mangled (stays 42): | ||
38 | (exit 42); a=Z env echo Visible:$? | ||
34 | 39 | ||
35 | unset a | 40 | echo |
36 | echo Fail:$?; true | 41 | true; unset a |
42 | echo Fail:$? | ||
diff --git a/shell/hush_test/hush-vars/readonly2.right b/shell/hush_test/hush-vars/readonly2.right new file mode 100644 index 000000000..5b02ddfe8 --- /dev/null +++ b/shell/hush_test/hush-vars/readonly2.right | |||
@@ -0,0 +1,4 @@ | |||
1 | hush: a=Z: readonly variable | ||
2 | Visible:42 | ||
3 | hush: a=Z: readonly variable | ||
4 | Visible:42 | ||
diff --git a/shell/hush_test/hush-vars/readonly2.tests b/shell/hush_test/hush-vars/readonly2.tests new file mode 100755 index 000000000..d9d178edd --- /dev/null +++ b/shell/hush_test/hush-vars/readonly2.tests | |||
@@ -0,0 +1,6 @@ | |||
1 | unset a | ||
2 | readonly a=A | ||
3 | |||
4 | # external commands and builtins should behave the same: | ||
5 | (exit 42); a=Z echo "Visible:$?" | ||
6 | (exit 42); a=Z env echo "Visible:$?" | ||