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
signature.asc Description: OpenPGP digital signature