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: Clark J. Wang
Subject: Re: variable name and its' value are the same characters causes recursion error
Date: Thu, 10 Mar 2011 10:16:42 +0800

On Thu, Mar 10, 2011 at 5:14 AM, Peggy Russell
<prusselltechgroup@gmail.com>wrote:

> > The existing documentation seems pretty clear:
> > ...
> > The value of a variable is evaluated as an arithmetic  expression  when
> > it  is  referenced, or when a variable which has been given the integer
> > attribute using declare -i is assigned a value.  A null value evaluates
> > to  0.   A shell variable need not have its integer attribute turned on
> > to be used in an expression.
>
> Hi Chet,
>
> I've reread that paragraph a number of times. It could be improved to
> help the end-user.
>
> After the sentence:
>
> "The value of a variable is evaluated as an arithmetic expression
> when it is referenced, ..."
>
> Add the sentence:
>
> This evaluation of the variables value will be performed
> recursively until an arithmetic evaluation is found or
> the expression recursion level exceeded.
>
>
Agree. I didn't know it's recursive before. :)


> 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?
>
> Thank you.
> Peg
>
>
>


-- 
Clark J. Wang


reply via email to

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