Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14542 > unrolled thread
| Started by | Chet Ramey <chet.ramey@case.edu> |
|---|---|
| First post | 2018-08-27 16:11 -0400 |
| Last post | 2018-08-27 16:11 -0400 |
| 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.
Re: bash 5.0 nested array subscript arithmetic expansion error Chet Ramey <chet.ramey@case.edu> - 2018-08-27 16:11 -0400
| From | Chet Ramey <chet.ramey@case.edu> |
|---|---|
| Date | 2018-08-27 16:11 -0400 |
| Subject | Re: bash 5.0 nested array subscript arithmetic expansion error |
| Message-ID | <mailman.13.1535400719.1284.bug-bash@gnu.org> |
On 8/27/18 12:25 PM, Grisha Levit wrote:
> This used to work:
>
> bash-4.4$ a=0
> bash-4.4$ echo $(( a[a[0]] ))
> 0
> bash-4.4$ echo ${a[a[a[0]]]}
> 0
>
> But is broken in bash-5.0:
>
> bash-5.0$ a=0
> bash-5.0$ echo ${a[a[a[0]]]}
> bash: a[a[0]]: syntax error: invalid arithmetic operator (error token is "]")
> bash-5.0$ echo $(( a[a[0]] ))
> bash: a[a[0]] : syntax error: invalid arithmetic operator (error token is "] ")
This is part of changes in bash-5.0 to avoid expanding array subscripts
more than one time. After expanding the subscript once, you don't want
to expand (or check) nested open and close brackets again -- how do you
get literal brackets into an associative array key, for instance? I'll take
a look and see if there's an easy way to allow this syntax, which -- you
have to admit -- is fairly obscure.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
Back to top | Article view | gnu.bash.bug
csiph-web