bug-bash
[Top][All Lists]
Advanced

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

Re: variable name and its' value are the same characters causes recursio


From: Eric Blake
Subject: Re: variable name and its' value are the same characters causes recursion error
Date: Wed, 09 Mar 2011 15:03:31 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7

On 03/09/2011 02:54 PM, Chet Ramey wrote:
>>
>> For example:
>>
>> unset a; declare a="a"; [[ a -lt 3 ]]; echo $?
>> bash: [[: a: expression recursion level exceeded (error token is "a")
>> 1
>>
>> Shouldn't the return code from this expression be 2, rather than 1?
> 
> What does it matter?  Failure is failure.

Except that [[ explicitly documents that 0 and 1 imply a syntactically
valid expression, reserving $?==2 for catastrophic failure.  The
argument here is that infinite recursion is catastrophic and represents
an invalid expression, and should not be confused with $?==1 meaning a
valid but false expression.  Similarly to expr(1) returning 0 and 1
depending on value for success, and > 1 on failure.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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