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

2011-03-10 Thread Maarten Billemont
On 10 Mar 2011, at 15:23, Chet Ramey wrote: > > On 3/10/11 8:14 AM, Greg Wooledge wrote: >> On Thu, Mar 10, 2011 at 10:18:26AM +0800, Clark J. Wang wrote: >>> Actually I don't like the recursion here. Does POSIX require that? >>> For example: unset a; declare a="a"; [[ a -lt 3 ]];

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

2011-03-10 Thread Chet Ramey
On 3/10/11 8:14 AM, Greg Wooledge wrote: > On Thu, Mar 10, 2011 at 10:18:26AM +0800, Clark J. Wang wrote: >> Actually I don't like the recursion here. Does POSIX require that? >> >>> For example: >>> >>> unset a; declare a="a"; [[ a -lt 3 ]]; echo $? >>> bash: [[: a: expression recursion level exce

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

2011-03-10 Thread Greg Wooledge
On Thu, Mar 10, 2011 at 10:18:26AM +0800, Clark J. Wang wrote: > Actually I don't like the recursion here. Does POSIX require that? > > > For example: > > > > unset a; declare a="a"; [[ a -lt 3 ]]; echo $? > > bash: [[: a: expression recursion level exceeded (error token is "a") > > 1 POSIX doesn

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

2011-03-09 Thread Clark J. Wang
On Thu, Mar 10, 2011 at 5:14 AM, Peggy Russell 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

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

2011-03-09 Thread Clark J. Wang
On Thu, Mar 10, 2011 at 5:14 AM, Peggy Russell 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

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

2011-03-09 Thread Chet Ramey
> 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 d

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

2011-03-09 Thread Eric Blake
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? Failur

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

2011-03-09 Thread Chet Ramey
> > 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. -- ``The lyf so short, the craft so

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

2011-03-09 Thread Peggy Russell
> 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 var

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

2011-03-09 Thread Chet Ramey
On 3/7/11 11:48 PM, Peggy Russell wrote: > It would be helpful if indirection was explained in the documentation for > [[ expression ]], [ expression ], and declare. The existing documentation seems pretty clear: Shell variables are allowed as operands; parameter expansion is per- formed befor

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

2011-03-07 Thread Peggy Russell
> Since those are not numeric, bash treats them as expressions to be > evaluated. You don't have to use the $ to obtain variable evaluation > when using [[ or [. You get: c=1;a="c";b=2;[[ a -lt b ]]; echo $? 0 c=3;a="c";b=2;[[ a -lt b ]]; echo $? 1 I see. I was aware of explicit indirection as

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

2011-03-07 Thread Chet Ramey
On 3/6/11 3:13 PM, Peggy Russell wrote: > Hi Chet, > > Summary > *** > When a variable name and its' value are the same characters (a="a"), > a recursion error occurs. Quite true. If you expand the problem expression, you get [[ a -lt b ]] Since those are not numeric, bash treats them as e

variable name and its' value are the same characters causes recursion error

2011-03-07 Thread Peggy Russell
Hi Chet, Summary *** When a variable name and its' value are the same characters (a="a"), a recursion error occurs. Steps to recreate "problem" *** Step 1: 1. Execute the command . a="cat";b="dog";[[