help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] declare -i


From: Greg Wooledge
Subject: Re: [Help-bash] declare -i
Date: Wed, 9 May 2012 16:55:03 -0400
User-agent: Mutt/1.4.2.3i

On Wed, May 09, 2012 at 02:43:31PM -0600, Bill Gradwohl wrote:
> Nope. Wasn't aware of it. Thank You for the education.

Math contexts do an infinitely-recursing indirect parameter expansion
thingy:

imadev:~$ a=b b=c c=d d=e e=f f=42; echo $((a))
42

And there seems to be a weird difference between these two that I don't
fully understand:

(with a, b, c, d, e, f still defined as above)

imadev:~$ unset x
imadev:~$ declare -i -a x=(a); echo "$x"
a

imadev:~$ unset x
imadev:~$ declare -i -a x; x=(a); echo "$x"
42

Based on the previous messages in this thread, I guess this happens
because in the first one, the (a) is evaluated as a list of strings
(since the evaluation occurs before the array has been made "-i"??),
while in the second one, (a) is evaluated as a list of math contexts,
since it's being assigned to a "-i" array.  I could be mistaken.



reply via email to

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