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