bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is this right? test -v $hash{defined_value} == false?


From: Charles Daffern
Subject: Re: Is this right? test -v $hash{defined_value} == false?
Date: Mon, 13 Jul 2015 07:04:00 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1

On 13/07/15 04:58, Linda Walsh wrote:
>>  [[ -v hash[defined_value] ]] || echo fail 
> fail
This one worked for me, both bare and in quotes.

>>  echo $BASH_VERSION
> 4.2.45(1)-release
I'm on 4.3.39(1)-release

> This seems more messy and isn't -v supposed
> to help clean up such things?
>>  [[ ${hash[defined_value]:-""} ]] || echo fail  #it passes
>>  [[ ${hash[defined_value1]:-""} ]] || echo fail
> fail
In non-bash shells I will usually use [ -n "${var+x}" ], because it
distinguishes between empty and unset variables.

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]