Re: bash can't distinguish between empty and unset arrays

2016-02-05 Thread Chet Ramey
On 2/3/16 6:43 PM, Martijn Dekker wrote: > bash treats an empty array as if it were an unset variable, which seems > very illogical as empty is quite distinct from unset: > > $ myarray=() > $ [[ -v myarray ]] && echo set || echo unset > unset If you use the name of an array in a variable context

Re: bash can't distinguish between empty and unset arrays

2016-02-03 Thread Stephane Chazelas
2016-02-03 23:43:37 +, Martijn Dekker: > bash treats an empty array as if it were an unset variable, which seems > very illogical as empty is quite distinct from unset: > > $ myarray=() > $ [[ -v myarray ]] && echo set || echo unset > unset [[ -v var ]] is for scalar variables (AFAICT). bash

Re: bash can't distinguish between empty and unset arrays

2016-02-03 Thread Reuti
Hi, Am 04.02.2016 um 00:43 schrieb Martijn Dekker: > bash treats an empty array as if it were an unset variable, which seems > very illogical as empty is quite distinct from unset: > > $ myarray=() > $ [[ -v myarray ]] && echo set || echo unset > unset Which version of bash are you using? > $

bash can't distinguish between empty and unset arrays

2016-02-03 Thread Martijn Dekker
bash treats an empty array as if it were an unset variable, which seems very illogical as empty is quite distinct from unset: $ myarray=() $ [[ -v myarray ]] && echo set || echo unset unset $ set | grep ^myarray= # yet, it's set: myarray=() $ set -u $ for i in "${x[@]}"; do :; done bash: x[@]: un