[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: test -v for array does not work as documented
From: |
Chet Ramey |
Subject: |
Re: test -v for array does not work as documented |
Date: |
Thu, 20 Feb 2020 14:37:18 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 |
On 2/20/20 10:05 AM, Ulrich Mueller wrote:
>>>>>> On Thu, 20 Feb 2020, pepa65 wrote:
>
>> On 20/02/2020 19.48, Ulrich Mueller wrote:
>>> 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.
>
>> There is no need to parse, the return value of `declare -p var` or
>> `typeset -p var` will tell you what you want.
>
> Unfortunately, it doesn't:
>
> $ f() {
> > local var
> > var="foo"
> > declare -p var
> > echo $?
> > unset var
> > declare -p var
> > echo $?
> > }
> $ f
> declare -- var="foo"
> 0
> declare -- var
> 0
It's unset because it doesn't have a value, but it retains the `local'
attribute so it stays local if subsequently assigned one.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
- Re: test -v for array does not work as documented, (continued)
- Re: test -v for array does not work as documented, Chet Ramey, 2020/02/19
- Re: test -v for array does not work as documented, Ulrich Mueller, 2020/02/19
- Re: test -v for array does not work as documented, Chet Ramey, 2020/02/19
- Re: test -v for array does not work as documented, pepa65, 2020/02/19
- Re: test -v for array does not work as documented, Stephane Chazelas, 2020/02/19
- 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, pepa65, 2020/02/20
- Re: test -v for array does not work as documented, Grisha Levit, 2020/02/19
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 <=
- 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