help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What has been changed in [[ -v x[@] ]]?


From: Chet Ramey
Subject: Re: What has been changed in [[ -v x[@] ]]?
Date: Mon, 17 Jul 2023 12:21:31 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 7/17/23 1:03 AM, Peng Yu wrote:
Hi,

I see the following change in the behavior of [[ -v x[@] ]]. Why is
there such a change?

It sometimes helps to follow along with bug-bash discussions.

https://lists.gnu.org/archive/html/bug-bash/2021-03/msg00059.html
https://lists.gnu.org/archive/html/bug-bash/2021-04/msg00058.html

What is the most efficient way to test whether an associated array is
empty, unset or does not exist?

There are really only two interesting states: with set elements and
without. You can see whether there are any set elements by testing
whether ${#a[@]} is greater than 0. If it's 0, there are no set elements.

--
``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/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]