Re: 4.4 change in behavior from 4.3: how to catch unset when using ${#length}

2016-10-21 Thread Eduardo Bustamante
what's wrong with?: echo ${#array[@]} It will return: - With array=(1 2 3) -> 3 - With array=() -> 0 - With unset array -> 0 - With declare -a array -> 0 Seems to do what you're looking for.

Re: 4.4 change in behavior from 4.3: how to catch unset when using ${#length}

2016-10-21 Thread L. A. Walsh
Eduardo Bustamante wrote: what's wrong with?: echo ${#array[@]} It will return: - With array=(1 2 3) -> 3 - With array=() -> 0 - With unset array -> 0 - With declare -a array -> 0 Seems to do what you're looking for. Not when "-u" is set, which I often have on to help catch misspellings

4.4 change in behavior from 4.3: how to catch unset when using ${#length}

2016-10-21 Thread L. A. Walsh
On 4.3 and earlier, at least on arrays, one could have the illusion of this working w/o complaint -- and returning 0 when the array was 0-len or unset, or the array length, otherwise: echo ${#array[@]:-0} But I note it only seemed to work in arrays, and in 4.4 gets a syntax error: echo ${#ar