[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fwd: Indices of array variables are sometimes considered unset (or just
Great Big Dot
Fwd: Indices of array variables are sometimes considered unset (or just display an error).
Tue, 6 Nov 2018 17:49:58 -0500
Crap, looks like I accidentally just replied to a single person instead of
the whole list. Here it is (and sorry if I'm uselessly cluttering up
---------- Forwarded message ---------
From: Great Big Dot <address@hidden>
Date: Tue, Nov 6, 2018 at 5:45 PM
Subject: Re: Indices of array variables are sometimes considered unset (or
just display an error).
> On Mon, Nov 5, 2018 at 10:38 PM Eduardo Bustamante <address@hidden>
> Sorry, I'm having a hard time following this email thread.
My bad, sorry if I wasn't clear enough. I expected this:
$ printf '%s\n' "address@hidden"
That is, I expected the keys of 'array' to be printed, unless the array was
unset. Instead, I either got errors or the "unset" string, and never the
actual keys. I didn't even realize that the indirection had something to do
with it, though once it hit me it made the behavior much clearer. I
implicitly assumed that the indirection stuff only applied to non-array
variables, and index-expansion only to array variables.
> What is your ultimate goal or the actual problem you're trying to solve?
Honestly, I was just messing around at the command line to get the hang of
some of the expansions. IIRC, I was looking at the "parameter
transformation" stuff ("address@hidden", "address@hidden", etc.). I was looking
edge cases that might trip me up in the future, and eventually I wondered
what would happen if you used an array. Somehow that led to me trying other
expansions with arrays, and I ended up getting errors I couldn't explain.
> (BTW, I would recommend against trying to do three expansions in one.
> It might be more terse, but it's hard to read and as you found out,
> leads to weird behavior)
Yeah, I think I'm starting to get that now...