Re: Two states of empty arrays

2019-12-12 Thread Martin Schulte
Hello Léa! Léa Gris wrote: > I was trying to play the the -v test to detect when an array or > associative array has been declared, not necessarily assigned entries > key, values, to not error when Bash runs with -o nounset Just for the curious: What is your attention here? I think that most us

Re: Two states of empty arrays

2019-12-12 Thread Léa Gris
Le 12/12/2019 à 20:13, Chet Ramey écrivait : >> # Empty array declared without parenthesis >> unset myArr >> declare -a myArr >> typeset -p myArr >> echo "${#myArr[@]}" > > This is an unset variable with the array attribute; you have not assigned a > value. >> # Empty array declared without paren

Re: Two states of empty arrays

2019-12-12 Thread Chet Ramey
On 12/12/19 12:08 PM, Léa Gris wrote: Hello, Depending on how an empty array is declared, it is not stored with the same state. # Empty array declared without parenthesis unset myArr declare -a myArr typeset -p myArr echo "${#myArr[@]}" This is an unset variable with the array attribute; you

Re: Two states of empty arrays

2019-12-12 Thread Clint Hepner
On Thu, Dec 12, 2019 at 1:10 PM Léa Gris wrote: > Hello, > > Depending on how an empty array is declared, it is not stored with the > same state. > > # Empty array declared without parenthesis > unset myArr > declare -a myArr > typeset -p myArr > echo "${#myArr[@]}" > > output: > declare -a myArr

Two states of empty arrays

2019-12-12 Thread Léa Gris
Hello, Depending on how an empty array is declared, it is not stored with the same state. # Empty array declared without parenthesis unset myArr declare -a myArr typeset -p myArr echo "${#myArr[@]}" output: declare -a myArr 0 # Empty array declared without parenthesis unset myArr declare -a myA