[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: test -v for array does not work as documented
From: |
pepa65 |
Subject: |
Re: test -v for array does not work as documented |
Date: |
Wed, 19 Feb 2020 23:52:54 +0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 |
On 19/02/2020 23.18, Ulrich Mueller wrote:
> So, is there any syntax that allows to test if a value has been assigned
> to the array variable? Especially, to distinguish VARNAME=() (empty
> array) from VARNAME being unset?
Not `test` as such as we have just learned, but the returncode of
`declare -p VARNAME` will be different for VARNAME being unset or being
set to `()` or `""`. Add `&>/dev/null` to taste..!
Peter