Re: variable name and its' value are the same characters causes recursio
From:
Peggy Russell
Subject:
Re: variable name and its' value are the same characters causes recursion error
Date:
Wed, 9 Mar 2011 21:14:22 +0000 (UTC)
User-agent:
Loom/3.14 (http://gmane.org/)
> 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.
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