aboutsummaryrefslogtreecommitdiff
path: root/shell/hush_test
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-07-18 02:44:06 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-07-18 02:44:06 +0200
commit5b2cc0aaee6985431d9bab1b49ceea7e1fa1d7af (patch)
tree456dfbf0232f7d0b0482bcc2eef96b6085fe98bd /shell/hush_test
parent38ef39a1abd46ca390b0259ebd0b35e9ea9ccb68 (diff)
downloadbusybox-w32-5b2cc0aaee6985431d9bab1b49ceea7e1fa1d7af.tar.gz
busybox-w32-5b2cc0aaee6985431d9bab1b49ceea7e1fa1d7af.tar.bz2
busybox-w32-5b2cc0aaee6985431d9bab1b49ceea7e1fa1d7af.zip
hush: do not assign to readonly VAR in "VAR=VAL CMD" syntax too
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush_test')
-rw-r--r--shell/hush_test/hush-vars/readonly0.right6
-rwxr-xr-xshell/hush_test/hush-vars/readonly0.tests30
2 files changed, 25 insertions, 11 deletions
diff --git a/shell/hush_test/hush-vars/readonly0.right b/shell/hush_test/hush-vars/readonly0.right
index 9688d2e5f..07ca6e07f 100644
--- a/shell/hush_test/hush-vars/readonly0.right
+++ b/shell/hush_test/hush-vars/readonly0.right
@@ -5,8 +5,10 @@ hush: a=A: readonly variable
5Fail:1 5Fail:1
6hush: a=A: readonly variable 6hush: a=A: readonly variable
7Fail:1 7Fail:1
8hush: a=A: readonly variable 8hush: a=Z: readonly variable
9Fail:1 9Fail:1
10Visible:0 10hush: a=Z: readonly variable
11b=B
12^^^a is not exported
11hush: a: readonly variable 13hush: a: readonly variable
12Fail:1 14Fail:1
diff --git a/shell/hush_test/hush-vars/readonly0.tests b/shell/hush_test/hush-vars/readonly0.tests
index 3845f76ac..3ace9b767 100755
--- a/shell/hush_test/hush-vars/readonly0.tests
+++ b/shell/hush_test/hush-vars/readonly0.tests
@@ -1,10 +1,12 @@
1unset a b
2
1readonly a=A 3readonly a=A
2b=B 4b=B
3readonly b 5readonly b
4# readonly on already readonly var is harmless 6# readonly on already readonly var is harmless:
5readonly b a 7readonly b a
6readonly | grep '^readonly [ab]=' 8readonly | grep '^readonly [ab]='
7# this should work 9# this should work:
8export a b 10export a b
9export -n a b 11export -n a b
10echo Ok:$? 12echo Ok:$?
@@ -12,13 +14,23 @@ env | grep -e^a= -e^b= # shows nothing
12 14
13# these should all fail (despite the same value being assigned) 15# these should all fail (despite the same value being assigned)
14# bash does not abort even in non-interactive more (in script) 16# bash does not abort even in non-interactive more (in script)
15true 17true; a=A
16a=A 18echo Fail:$?
17echo Fail:$?; true 19true; readonly a=A
18readonly a=A 20echo Fail:$?
19echo Fail:$?; true 21
20export a=A 22# in bash, assignment in export fails, but export succeeds! :)
23# we don't mimic that!
24true; export a=Z
21echo Fail:$?; true 25echo Fail:$?; true
22a=A echo Visible:$? # command still runs 26#env | grep '^a='
27#echo "^^^a is exported"
28export -n a # undo that bashism, if it happens
29
30export b
31# this fails to both set and export a:
32a=Z env | grep '^[ab]=' # command still runs
33echo "^^^a is not exported"
34
23unset a 35unset a
24echo Fail:$?; true 36echo Fail:$?; true