[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] declare -i
From: |
Chet Ramey |
Subject: |
Re: [Help-bash] declare -i |
Date: |
Wed, 09 May 2012 17:01:28 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 |
On 5/9/12 4:55 PM, Greg Wooledge wrote:
> 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.
Pretty close, I'd bet. Without checking the code (too many meetings this
afternoon), I'd say that attribute assignment is deferred until after the
value assignment so that `declare -r foo=bar' works.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/
- [Help-bash] declare -i, Bill Gradwohl, 2012/05/08
- Re: [Help-bash] declare -i, Dan Douglas, 2012/05/09
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/09
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/09
- Re: [Help-bash] declare -i, Chet Ramey, 2012/05/09
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/09
- Re: [Help-bash] declare -i, Greg Wooledge, 2012/05/09
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/09
- Re: [Help-bash] declare -i, DJ Mills, 2012/05/09
- Re: [Help-bash] declare -i, Greg Wooledge, 2012/05/09
- Re: [Help-bash] declare -i,
Chet Ramey <=
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/09
- Re: [Help-bash] declare -i, Dan Douglas, 2012/05/09
- Re: [Help-bash] declare -i, Greg Wooledge, 2012/05/10
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/10
- Re: [Help-bash] declare -i, Chet Ramey, 2012/05/10
- Re: [Help-bash] declare -i, Greg Wooledge, 2012/05/10
- Re: [Help-bash] declare -i, Chet Ramey, 2012/05/10
- Re: [Help-bash] declare -i, Dan Douglas, 2012/05/10
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/10
- Re: [Help-bash] declare -i, Clark WANG, 2012/05/09