Fwd: Indices of array variables are sometimes considered unset (or just display an error).

2018-11-06 Thread Great Big Dot
s of array variables are sometimes considered unset (or just display an error). To: > On Mon, Nov 5, 2018 at 10:38 PM Eduardo Bustamante wrote: > Sorry, I'm having a hard time following this email thread. My bad, sorry if I wasn't clear enough. I expected this: $ array=(foo)

Indices of array variables are sometimes considered unset (or just display an error).

2018-11-06 Thread Great Big Dot
On 11/5/18 8:44 PM, Great Big Dot wrote: > > What's actually happening here is that the *indirection* expansion > > "${!foo}", and not the *indices* expansion "${!foo[@]}", is what is being > > preformed on something like "${!array[@]-}". Both expansions, while > > unrelated, happen to use the sam

Re: Indices of array variables are sometimes considered unset (or just display an error).

2018-11-06 Thread Chet Ramey
On 11/5/18 8:44 PM, Great Big Dot wrote: > What's actually happening here is that the *indirection* expansion > "${!foo}", and not the *indices* expansion "${!foo[@]}", is what is being > preformed on something like "${!array[@]-}". Both expansions, while > unrelated, happen to use the same syntax

Re: Indices of array variables are sometimes considered unset (or just display an error).

2018-11-06 Thread Chet Ramey
On 11/5/18 4:42 PM, Great Big Dot wrote: > Description: > The parameter expansion "${!var[@]}" expands to the indices of an array > (whether linear or associative). The expansion "${var-string}" > returns "${var}" iff var is set and 'string' otherwise. These two > features do not

Re: Indices of array variables are sometimes considered unset (or just display an error).

2018-11-06 Thread Greg Wooledge
On Mon, Nov 05, 2018 at 08:04:49PM -0500, Great Big Dot wrote: > Hold up... when I view this email on the public archives, all of my > "${array[@]}"'s (that is, "${array[]}"'a) got turned to > "address@hidden"'s. Sadly, there's nothing we can do about that. The maintainers of the list archive wou

Re: Indices of array variables are sometimes considered unset (or just display an error).

2018-11-05 Thread Grisha Levit
On Mon, Nov 5, 2018 at 10:38 PM Eduardo Bustamante wrote: > Sorry, I'm having a hard time following this email thread. I *think* the point is that OP expected that: (a) ${!var[@]-foo} expands to the indexes of var if ${var[@]} if set, else to `foo' whereas the behavior they observed is: (b

Re: Indices of array variables are sometimes considered unset (or just display an error).

2018-11-05 Thread Eduardo Bustamante
On Mon, Nov 5, 2018 at 6:01 PM Great Big Dot wrote: (...) > > [... A]ccessing the index list of multiple-element arrays > > fails when you append the unset expansion. With single-element > > arrays, it fails iff the element in question contains any special > > characters or whitespace, and thinks

Re: Indices of array variables are sometimes considered unset (or just display an error).

2018-11-05 Thread Great Big Dot
> On Mon, Nov 5, 2018 at 4:56 PM Great Big Dot wrote: > [... A]ccessing the index list of multiple-element arrays > fails when you append the unset expansion. With single-element > arrays, it fails iff the element in question contains any special > characters or whitespace, and thinks the array is

Re: Indices of array variables are sometimes considered unset (or just display an error).

2018-11-05 Thread Great Big Dot
On Mon, Nov 5, 2018 at 4:56 PM Great Big Dot wrote: > The parameter expansion "${!var[@]}" expands to the indices of an array (whether linear or associative). Hold up... when I view this email on the public archives, all of my "${array[@]}"'s (that is, "${array[]}"'a) got turned to "address@hidde

Indices of array variables are sometimes considered unset (or just display an error).

2018-11-05 Thread Great Big Dot
uname output: Linux ArchBox0 4.18.16-arch1-1-ARCH #1 SMP PREEMPT Sat Oct 20 22:06:45 UTC 2018 x86_64 GNU/Linux Machine Type: x86_64-unknown-linux-gnu Bash Version: 4.4 Patch Level: 23 Release Status: release --text follows this line-- Description: The parameter expansion "${!var[@]}" expan