[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: test -v difference between bash 5.1 and 5.2
From: |
Kerin Millar |
Subject: |
Re: test -v difference between bash 5.1 and 5.2 |
Date: |
Tue, 29 Aug 2023 16:38:41 +0100 |
On Tue, 29 Aug 2023 11:24:43 -0400
Chet Ramey <chet.ramey@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".
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.
$ unset -v assoc; assoc=; (( ${#assoc[@]} > 0 )); echo $?
0
--
Kerin Millar
Re: test -v difference between bash 5.1 and 5.2, Kerin Millar, 2023/08/29