aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-07-18 03:23:07 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-07-18 03:23:07 +0200
commitf645e1573c5521c87b972400f9b4abc3636983d4 (patch)
tree89e95e92045f83a5dacf518c2c6a0dafc7185cd2
parent5b2cc0aaee6985431d9bab1b49ceea7e1fa1d7af (diff)
downloadbusybox-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.right6
-rwxr-xr-xshell/hush_test/hush-vars/readonly0.tests16
-rw-r--r--shell/hush_test/hush-vars/readonly2.right4
-rwxr-xr-xshell/hush_test/hush-vars/readonly2.tests6
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 @@
1readonly a=A 1readonly a=A
2readonly b=B 2readonly b=B
3Ok:0 3Ok:0
4
4hush: a=A: readonly variable 5hush: a=A: readonly variable
5Fail:1 6Fail:1
6hush: a=A: readonly variable 7hush: a=A: readonly variable
7Fail:1 8Fail:1
9
8hush: a=Z: readonly variable 10hush: a=Z: readonly variable
9Fail:1 11Fail:1
12
10hush: a=Z: readonly variable 13hush: a=Z: readonly variable
11b=B 14b=B
12^^^a is not exported 15^^^a is not exported
16hush: a=Z: readonly variable
17Visible:42
18
13hush: a: readonly variable 19hush: a: readonly variable
14Fail:1 20Fail: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 @@
1unset a b 1unset a b
2 2#
3readonly a=A 3readonly a=A
4b=B 4b=B
5readonly b 5readonly b
@@ -12,6 +12,7 @@ export -n a b
12echo Ok:$? 12echo Ok:$?
13env | grep -e^a= -e^b= # shows nothing 13env | grep -e^a= -e^b= # shows nothing
14 14
15echo
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)
17true; a=A 18true; a=A
@@ -19,18 +20,23 @@ echo Fail:$?
19true; readonly a=A 20true; readonly a=A
20echo Fail:$? 21echo Fail:$?
21 22
23echo
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!
24true; export a=Z 26true; export a=Z
25echo Fail:$?; true 27echo Fail:$?
26#env | grep '^a=' 28#env | grep '^a='
27#echo "^^^a is exported" 29#echo "^^^a is exported"
28export -n a # undo that bashism, if it happens 30export -n a # undo that bashism, if it happens
29 31
32echo
30export b 33export b
31# this fails to both set and export a: 34# this fails to both set and export a:
32a=Z env | grep '^[ab]=' # command still runs 35a=Z env | grep '^[ab]='
33echo "^^^a is not exported" 36echo "^^^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
35unset a 40echo
36echo Fail:$?; true 41true; unset a
42echo 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 @@
1hush: a=Z: readonly variable
2Visible:42
3hush: a=Z: readonly variable
4Visible: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 @@
1unset a
2readonly 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:$?"