On 8/29/23 11:38 AM, Kerin Millar wrote:
On Tue, 29 Aug 2023 11:24:43 -0400
Chet Ramey <chet.ra...@case.edu> wrote:

If you want to check whether an array variable is set, you can check
whether it has any set elements:

(( ${#assoc[@]} > 0 ))

This doesn't check whether an "array variable is set".

It checks whether there are any set elements. You have to assign a value
to set a variable.

Not only that, but the test will be true in the case that assoc has been 
defined as a variable that is not an array.

One hopes that the shell programmer knows what variable types he's
using, and uses the appropriate constructs.

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


Reply via email to