[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: test -v for array does not work as documented
From: |
Ulrich Mueller |
Subject: |
Re: test -v for array does not work as documented |
Date: |
Thu, 20 Feb 2020 13:48:51 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.60 (gnu/linux) |
>>>>> 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.
- Re: test -v for array does not work as documented, Ulrich Mueller, 2020/02/20
- Re: test -v for array does not work as documented, Greg Wooledge, 2020/02/20
- Re: test -v for array does not work as documented, Chet Ramey, 2020/02/20
- Re: test -v for array does not work as documented, Ulrich Mueller, 2020/02/21
- Re: test -v for array does not work as documented, pepa65, 2020/02/21
- Re: test -v for array does not work as documented, Chet Ramey, 2020/02/23
- Re: test -v for array does not work as documented, pepa65, 2020/02/23
- Re: test -v for array does not work as documented, Chet Ramey, 2020/02/23