|
|
@@ -15,10 +15,31 @@ a=(1 '2 3') |
|
|
argv.py ${a[@]} ${a[*]}
|
|
|
# stdout: ['1', '2', '3', '1', '2', '3']
|
|
|
|
|
|
### Empty array tests
|
|
|
### 4 ways to interpolate empty array
|
|
|
argv.py 1 "${a[@]}" 2 ${a[@]} 3 "${a[*]}" 4 ${a[*]} 5
|
|
|
# stdout: ['1', '2', '3', '', '4', '5']
|
|
|
|
|
|
### empty array
|
|
|
empty=()
|
|
|
argv.py "${empty[@]}"
|
|
|
# stdout: []
|
|
|
|
|
|
### Empty array with :-
|
|
|
empty=()
|
|
|
argv.py ${empty[@]:-not one} "${empty[@]:-not one}"
|
|
|
# stdout: ['not', 'one', 'not one']
|
|
|
|
|
|
### nounset with empty array (design bug, makes it hard to use arrays)
|
|
|
# http://lists.gnu.org/archive/html/help-bash/2017-09/msg00005.html
|
|
|
# TODO: sane-arrays should get rid of this problem.
|
|
|
set -o nounset
|
|
|
empty=()
|
|
|
argv.py "${empty[@]}"
|
|
|
echo status=$?
|
|
|
# stdout-json: "[]\nstatus=0\n"
|
|
|
# BUG bash/mksh stdout-json: ""
|
|
|
# BUG bash/mksh status: 1
|
|
|
|
|
|
### local array
|
|
|
# mksh support local variables, but not local arrays, oddly.
|
|
|
f() {
|
|
|
@@ -63,11 +84,6 @@ argv.py "${a[@]}" |
|
|
# status: 2
|
|
|
# OK mksh status: 1
|
|
|
|
|
|
### empty array
|
|
|
empty=()
|
|
|
argv.py "${empty[@]}"
|
|
|
# stdout: []
|
|
|
|
|
|
### array with empty string
|
|
|
empty=('')
|
|
|
argv.py "${empty[@]}"
|
|
|
@@ -266,11 +282,6 @@ ls foo=(1 2) |
|
|
# status: 2
|
|
|
# OK mksh status: 1
|
|
|
|
|
|
### Empty array with :-
|
|
|
empty=()
|
|
|
argv.py ${empty[@]:-not one} "${empty[@]:-not one}"
|
|
|
# stdout: ['not', 'one', 'not one']
|
|
|
|
|
|
### Single array with :-
|
|
|
# bash does EMPTY ELISION here, unless it's double quoted. mksh has
|
|
|
# more sane behavior. OSH is better.
|
|
|
|
0 comments on commit
76af99b