>>>>> On Wed, 19 Feb 2020, Stephane Chazelas wrote:

> 2020-02-19 17:18:14 +0100, Ulrich Mueller:
> [...]
>> 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?
> [...]

> You could do:

> if typeset -p var 2> /dev/null | grep -q '='; then
>   echo var has a value
> fi

> [...]

Yes, basically that's what I had suggested as a workaround in the
downstream bug: https://bugs.gentoo.org/710076#c2

Still, I think it's sad that there isn't a command that can test for
assigned vs void variable, without the need for parsing of declare -p
output.

Reply via email to