shell: remove ${#+} tests, it is not a valid construct
[oweals/busybox.git] / shell / hush_test / hush-vars / readonly0.tests
1 unset a b
2 #
3 readonly a=A
4 b=B
5 readonly b
6 # readonly on already readonly var is harmless:
7 readonly b a
8 readonly | grep '^readonly [ab]='
9 # this should work:
10 export a b
11 export -n a b
12 echo Ok:$?
13 env | grep -e^a= -e^b=  # shows nothing
14
15 echo
16 # these should all fail (despite the same value being assigned)
17 # bash does not abort even in non-interactive more (in script)
18 true; a=A
19 echo Fail:$?
20 true; readonly a=A
21 echo Fail:$?
22
23 echo
24 # in bash, assignment in export fails, but export succeeds! :)
25 # we don't mimic that!
26 true; export a=Z
27 echo Fail:$?
28 #env | grep '^a='
29 #echo "^^^a is exported"
30 export -n a  # undo that bashism, if it happens
31
32 echo
33 export b
34 # this fails to both set and export a:
35 a=Z env | grep '^[ab]='
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:$?
39
40 echo
41 true; unset a
42 echo Fail:$?