Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14774 > unrolled thread
| Started by | Great Big Dot <greatbigdot@gmail.com> |
|---|---|
| First post | 2018-11-06 17:49 -0500 |
| Last post | 2018-11-06 17:49 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to gnu.bash.bug
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Fwd: Indices of array variables are sometimes considered unset (or just display an error). Great Big Dot <greatbigdot@gmail.com> - 2018-11-06 17:49 -0500
| From | Great Big Dot <greatbigdot@gmail.com> |
|---|---|
| Date | 2018-11-06 17:49 -0500 |
| Subject | Fwd: Indices of array variables are sometimes considered unset (or just display an error). |
| Message-ID | <mailman.3591.1541544626.1284.bug-bash@gnu.org> |
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
everyone's inboxes!):
---------- Forwarded message ---------
From: Great Big Dot <greatbigdot@gmail.com>
Date: Tue, Nov 6, 2018 at 5:45 PM
Subject: Re: Indices of array variables are sometimes considered unset (or
just display an error).
To: <dualbus@gmail.com>
> On Mon, Nov 5, 2018 at 10:38 PM Eduardo Bustamante <dualbus@gmail.com>
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)
$ printf '%s\n' "${!array[@]-unset}"
0
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 ("${var@Q}", "${var@A}", etc.). I was looking for any
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...
Back to top | Article view | gnu.bash.bug
csiph-web