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

2016-11-09 Thread Chet Ramey
On 11/7/16 4:49 AM, Dan Douglas wrote: > On Sun, Nov 6, 2016 at 3:46 PM, Chet Ramey wrote: >> On 11/1/16 5:57 AM, Dan Douglas wrote: >>> On a possibly related note, would you consider adjusting +, :+, -, :-, >>> as in "${var[@]+word}" to align with the meaning of [[ -v var[@] ]] as >>> discussed i

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

2016-11-07 Thread Dan Douglas
On Sun, Nov 6, 2016 at 3:46 PM, Chet Ramey wrote: > On 11/1/16 5:57 AM, Dan Douglas wrote: >> On a possibly related note, would you consider adjusting +, :+, -, :-, >> as in "${var[@]+word}" to align with the meaning of [[ -v var[@] ]] as >> discussed in >> https://lists.gnu.org/archive/html/bug-

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

2016-11-06 Thread Chet Ramey
On 11/1/16 5:57 AM, Dan Douglas wrote: > On Mon, Oct 24, 2016 at 8:25 AM, Chet Ramey wrote: >> On 10/21/16 5:41 PM, L. A. Walsh wrote: >>> 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,

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

2016-11-01 Thread Dan Douglas
On Mon, Oct 24, 2016 at 8:25 AM, Chet Ramey wrote: > On 10/21/16 5:41 PM, L. A. Walsh wrote: >> 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: >> >> >>

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

2016-10-29 Thread L. A. Walsh
Chet Ramey wrote: On 10/29/16 2:04 AM, L. A. Walsh wrote: You can claim a feature is a certain way because posix requires it when you are operating in posix-only mode. Not actually true. I can claim bash implements a particular feature the way bash implements it. --- True, but

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

2016-10-29 Thread Chet Ramey
On 10/29/16 2:04 AM, L. A. Walsh wrote: > > > Chet Ramey wrote: >> Come on, don't be willfully obtuse. You know better than this. Posix mode >> doesn't mean "turning it off does everything the way Linda wants." >> > No, but claiming posix as a backing for features running that are > not runnin

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

2016-10-28 Thread L. A. Walsh
Chet Ramey wrote: Come on, don't be willfully obtuse. You know better than this. Posix mode doesn't mean "turning it off does everything the way Linda wants." No, but claiming posix as a backing for features running that are not running with posix-mode set, is equally obtuse. Bash is not l

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

2016-10-28 Thread Chet Ramey
On 10/28/16 3:43 PM, L. A. Walsh wrote: > >Please, I'm not running in posix mode, so how would their rules > apply? Because you're using `bash', not `walsh'? Bash is a posix shell. Would the bash documentation convince you? You could go read that instead. > Just because posix defines

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

2016-10-28 Thread L. A. Walsh
Chet Ramey wrote: On 10/24/16 7:32 PM, L. A. Walsh wrote: I don't understand the ambiguity. If param= "#obj[@]", then it is clear to me that the user wants the length of an array named "obj". Stop there. In something like ${#obj[@]}, `param' is `obj[@]'. The `${#param}' is a c

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

2016-10-28 Thread Chet Ramey
On 10/24/16 7:32 PM, L. A. Walsh wrote: >I don't understand the ambiguity. If param= "#obj[@]", then it > is clear to me that the user wants the length of an array named "obj". Stop there. In something like ${#obj[@]}, `param' is `obj[@]'. The `${#param}' is a clearly-defined word expansio

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

2016-10-24 Thread L. A. Walsh
Chet Ramey wrote: On 10/21/16 5:41 PM, L. A. Walsh wrote: [previously] 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

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

2016-10-24 Thread Chet Ramey
On 10/21/16 5:41 PM, L. A. Walsh wrote: > 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 wor

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

2016-10-24 Thread Greg Wooledge
On Fri, Oct 21, 2016 at 09:19:08PM -0700, L. A. Walsh wrote: > Eduardo Bustamante wrote: > >what's wrong with?: > >echo ${#array[@]} > Not when "-u" is set, which I often have on to help catch misspellings. > > set -u > echo ${#array[@]} > bash: array: unbound variable See http://mywiki.wooledge

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