1 ## compare_shells: bash mksh zsh
2
3 # Common between bash/zsh
4
5 #### "${a[@]}" and "${a[*]}"
6 a=(1 '2 3')
7 argv.py "${a[@]}" "${a[*]}"
8 ## stdout: ['1', '2 3', '1 2 3']
9
10 #### ${a[@]} and ${a[*]}
11 a=(1 '2 3')
12 argv.py ${a[@]} ${a[*]}
13 ## STDOUT:
14 ['1', '2', '3', '1', '2', '3']
15 ## END
16 ## BUG zsh STDOUT:
17 ['1', '2 3', '1', '2 3']
18 ## END
19
20 #### 4 ways to interpolate empty array
21 argv.py 1 "${a[@]}" 2 ${a[@]} 3 "${a[*]}" 4 ${a[*]} 5
22 ## STDOUT:
23 ['1', '2', '3', '', '4', '5']
24 ## END
25
26 ## BUG zsh STDOUT:
27 ['1', '', '2', '3', '', '4', '5']
28 ## END
29
30 #### empty array
31 empty=()
32 argv.py "${empty[@]}"
33 ## STDOUT:
34 []
35 ## END
36
37 #### Empty array with :-
38 empty=()
39 argv.py ${empty[@]:-not one} "${empty[@]:-not one}"
40 ## STDOUT:
41 ['not', 'one', 'not one']
42 ## END
43 ## BUG zsh STDOUT:
44 ['not one', 'not one']
45 ## END