OILS / spec / assign-dialects.test.sh View on Github | oilshell.org

61 lines, 39 significant
1## oils_failures_allowed: 1
2## compare_shells: bash mksh
3
4#### K and V are variables in (( array[K] = V ))
5K=5
6V=42
7typeset -a array
8(( array[K] = V ))
9
10echo array[5]=${array[5]}
11echo keys = ${!array[@]}
12echo values = ${array[@]}
13## STDOUT:
14array[5]=42
15keys = 5
16values = 42
17## END
18
19#### when are variables set with 'test -v'
20test -v unset
21echo unset=$?
22
23typeset -a a
24test -v a
25echo a=$?
26
27typeset -A A
28test -v A
29echo A=$?
30
31a[0]=1
32A['x']=x
33
34test -v a
35echo a=$?
36
37# NOTE: This is a BUG! A is set
38test -v A
39echo A=$?
40
41## STDOUT:
42unset=1
43a=1
44A=1
45a=0
46A=0
47## END
48## BUG bash STDOUT:
49unset=1
50a=1
51A=1
52a=0
53A=1
54## END
55## N-I mksh STDOUT:
56unset=2
57a=2
58A=2
59a=2
60A=2
61## END