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 c...@case.edu http://tiswww.cwru.edu/~chet/