Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11961
| From | Chet Ramey <chet.ramey@case.edu> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: bug with getting an array index or ... |
| Date | 2015-12-06 13:50 -0500 |
| Organization | ITS, Case Western Reserve University |
| Message-ID | <mailman.1521.1449427816.31583.bug-bash@gnu.org> (permalink) |
| References | <CAH_OBidDQj8G60kKiEVPo46o=s8-UC-pKT1a=qjEn7XVHxo7HA@mail.gmail.com> <CAJnmqwYxCYUzNSkQjDyShZe0GK9KRG9jR+5yXH9kFO0UxTQA2A@mail.gmail.com> |
On 12/6/15 10:18 AM, konsolebox wrote:
> On Sun, Dec 6, 2015 at 9:38 PM, shawn wilson <ag4ve.us@gmail.com> wrote:
>> declare -a array=(aaaaaaaa bbbbbbbb cccccccc); echo "${!array[@]}";
>> echo "${!array[@]:-}"
>>
>> also, "${!array[@]:foo}" and :+foo and :-foo are all empty as well -
>> I'm pretty sure this is not intended?
>>
> ${!name[@]:-word}, ${!name[@]:+word}, and ${!name[@]:offset:length}
> are not explicitly documented as valid forms of parameter expansion,
> and never has been.
Yes. The only documented way to get that construct to produce the list of
indices is to use it like ${!array[@]}.
When you use it in a different expansion, you get standard variable
indirection: expand ${array[@]} and try to use it as a variable name.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
Back to gnu.bash.bug | Previous | Next | Find similar
Re: bug with getting an array index or ... Chet Ramey <chet.ramey@case.edu> - 2015-12-06 13:50 -0500
csiph-web