[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Changing the way bash expands associative array subscripts
From: |
Chet Ramey |
Subject: |
Re: Changing the way bash expands associative array subscripts |
Date: |
Mon, 12 Apr 2021 10:05:24 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 |
On 4/6/21 12:46 PM, Koichi Murase wrote:
How about the cases with `test -v a[@]' and `key=@; test -v a[$key]'?
By the time test sees its arguments, there is no difference between these
two cases. You can do things to differentiate when running the `[['
command, but `test' goes through the entire set of word expansions.
I remember there was some discussion in the bug-bash list on the
behavior of `test -v a[@]' which actually tests whether the array `a'
has at least one element. It cannot be replaced by `test -v a' because
`a' implies `a[0]' here. But if I correctly understand it, `test -v
a[@]' can be replaced by `((${#a[@]}))'. Should any scripts relying on
`test -v a[@]' to test the array elements also be changed?
I'm ok with making the old behavior contingent on a compatibility setting,
like with `unset'.
--
``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/
- Re: Changing the way bash expands associative array subscripts, (continued)
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/15
- Re: Changing the way bash expands associative array subscripts, konsolebox, 2021/04/15
- Re: Changing the way bash expands associative array subscripts, Koichi Murase, 2021/04/16
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/18
- Re: Changing the way bash expands associative array subscripts, konsolebox, 2021/04/18
- Re: Changing the way bash expands associative array subscripts, Koichi Murase, 2021/04/19
- Re: Changing the way bash expands associative array subscripts, konsolebox, 2021/04/08
- Re: Changing the way bash expands associative array subscripts, konsolebox, 2021/04/08
- Re: Changing the way bash expands associative array subscripts, Greg Wooledge, 2021/04/09
- Re: Changing the way bash expands associative array subscripts, konsolebox, 2021/04/09
- Re: Changing the way bash expands associative array subscripts,
Chet Ramey <=
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/12
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/08
- Re: Changing the way bash expands associative array subscripts, L A Walsh, 2021/04/13
- Re: Changing the way bash expands associative array subscripts, konsolebox, 2021/04/13
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/13
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/08
- Re: Changing the way bash expands associative array subscripts, konsolebox, 2021/04/06
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/08
- Re: Changing the way bash expands associative array subscripts, konsolebox, 2021/04/08
- Re: Changing the way bash expands associative array subscripts, Chet Ramey, 2021/04/08