bug-bash
[Top][All Lists]
Advanced

[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: Linda Walsh
Subject: Re: Minor bug declaring arrays of integers: dcl -ai=>broken, dcl -ia=>ok
Date: Tue, 23 Jul 2013 14:57:15 -0700
User-agent: Thunderbird


Chet Ramey wrote:
> 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.
----
    -l and -u also share the behavior:  Maybe someone might take a stab at
documenting
this behavior

> declare -la low=(one TWO thREE)
> echo "${low[@]}"
one TWO thREE
> declare -ua low=(one TWO thREE)
> echo ${low[@]}                 
one two three
low=$LOW
>
> There is a fairly powerful argument for backwards compatibility here...
eheh hehm (clearing throat)... with the above?!?  Eeek.  Um... If you
feel that strongly about it could implement it as a shopt-compatXX option,
but I still would love to  see a clear description of what the above is
intended or does do.  ;-/

But if you are talking Backwards compat....  *smile*, ....
Having -e exit only when a simple command fails would make it backwards
compat with almost 15 (at least since the 99posix spec)+ years of shell, and
 having 'tab's inserted on a line containing
nothing but tabs (i.e. at the beginning) NOT corrupt input would be backward
compatible with about 20-30 years of shell... 

Certainly those would have an even more _powerful_ argument for
for backwards compatibility than something
only a few years old?

    Wouldn't have mentioned them, but you did bring up backwards compatibility 
;-).
> Dan's suggestion of a workaround by quoting the rhs of the assignment
> statement is a good one.
----
    Sure -- especially if one could disable tab expansion inside of quotes and 
at
the beginning of a line  - kill two birds w/one stone, so to speak.  ;-)
>
> 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



reply via email to

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