[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Minor bug declaring arrays of integers: dcl -ai=>broken, dcl -ia=>ok
From: |
Chet Ramey |
Subject: |
Re: Minor bug declaring arrays of integers: dcl -ai=>broken, dcl -ia=>ok |
Date: |
Mon, 22 Jul 2013 09:07:35 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 |
On 7/21/13 10:35 PM, Dan Douglas wrote:
> What's the bug? I can't reproduce this and always get "xx" no mater the
> option
> order.
>
> I always assumed the -i attribute doesn't get set until after assigning the
> values, which is why:
>
> $ ( declare -ia foo=(1 2 xx 3); echo "${foo[@]}" )
> 1 2 xx 3
The issue is whether or not attributes that determine how the assignment
should be treated (-a/-A) or how the variable should be created (-g) are
handled specially and affect how the value is expanded. The question
is why -i should be omitted from that list.
There is a fairly powerful argument for backwards compatibility here:
Dan's suggestion of a workaround by quoting the rhs of the assignment
statement is a good one.
The other side of the argument is consistency. declare -A foo=(whatever)
changes how the array indices are expanded. Why should -i be different?
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
- Minor bug declaring arrays of integers: dcl -ai=>broken, dcl -ia=>ok, Linda Walsh, 2013/07/14
- Re: Minor bug declaring arrays of integers: dcl -ai=>broken, dcl -ia=>ok, Chet Ramey, 2013/07/21
- Re: Minor bug declaring arrays of integers: dcl -ai=>broken, dcl -ia=>ok, Dan Douglas, 2013/07/21
- Re: Minor bug declaring arrays of integers: dcl -ai=>broken, dcl -ia=>ok, Linda Walsh, 2013/07/21
- Re: Minor bug declaring arrays of integers: dcl -ai=>broken, dcl -ia=>ok, Dan Douglas, 2013/07/21
- Re: Minor bug declaring arrays of integers: dcl -ai=>broken, dcl -ia=>ok, Linda Walsh, 2013/07/22
- Re: Minor bug declaring arrays of integers: dcl -ai=>broken, dcl -ia=>ok, Dan Douglas, 2013/07/22
- Re: Minor bug declaring arrays of integers: dcl -ai=>broken, dcl -ia=>ok,
Chet Ramey <=
- Re: Minor bug declaring arrays of integers: dcl -ai=>broken, dcl -ia=>ok, Linda Walsh, 2013/07/23
- Re: Minor bug declaring arrays of integers: dcl -ai=>broken, dcl -ia=>ok, Chet Ramey, 2013/07/27
- Re: Minor bug declaring arrays of integers: dcl -ai=>broken, dcl -ia=>ok, Linda Walsh, 2013/07/28
- Re: Minor bug declaring arrays of integers: dcl -ai=>broken, dcl -ia=>ok, Dan Douglas, 2013/07/28