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: alex xmb ratchev
Subject: Re: What has been changed in [[ -v x[@] ]]?
Date: Tue, 18 Jul 2023 11:03:09 +0200

On Mon, Jul 17, 2023, 6:22 PM Chet Ramey <chet.ramey@case.edu> wrote:

> 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.
>

and a minor content check , there may be args but empty

 [[ ${@[*]} ]] ||
echo no args content

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