Bash manual says:
Referencing an array variable without a subscript is equivalent to referencing with a subscript of 0.
In Bash or POSIX shell, is there some general rule for when an array variable represents the entire array, and when it represents the element indexed by 0
?
For example,
It seems that after
declare
an array variable means the entire array, while in parameter expansion, it means the element indexed by0
:$ declare -p x declare -a x='([1]="b" [2]="c")' $ echo $x
- In
[[ -v myarr ]]
, doesmyarr
mean the array ormyarr[0]
?