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: Sun, 21 Jul 2013 20:39:29 -0700
User-agent: Thunderbird


Dan Douglas wrote:
> On Sunday, July 21, 2013 04:13:31 PM Chet Ramey wrote:
>> (For what it's worth, I don't see a difference in the output no matter what
>> the option order.)
>> Chet
> 
> What's the bug? I can't reproduce this and always get "xx" no mater the 
> option 
> order.
----
        Yeah... you're both right.

it happened if you execute the statement a 2nd time, the 1st time
set's up the 2nd time for success:

function xx {
  typeset -gia foo=(1 2 NaN 3)
  echo "foo=\"address@hidden""
}
---
Executed the first time:
> xx
foo="1 2 NaN 3"
2nd time...(same func)

> xx
foo="1 2 0 3"


> I always assumed the -i attribute doesn't get set until after assigning the 
> values, which is why:
---
I don't think so.   Not from the above.

The first sets up an array outside the function composed of integers,
so the 2nd time I execute  the same, it gets put through the "integer strainer".

The bug is that the "-i" isn't applied until after the array assignment
is done.. which isn't the case for scalars:

> declare -i v=xx
> echo $v
0

i.e. -i delays it's property effect until after the array has been assigned
which is why it works when you run it a 2nd time, but with scalars,
it works the 1st time.  Same thing happens with the "upper/lower case" 
attributes:

> declare -la low=(aa BBB cCC Ddd) 
> echo address@hidden
aa BBB cCC Ddd
> declare -la low=(aa BBB cCC Ddd)
> echo address@hidden                  
aa bbb ccc ddd

(no function needed).





reply via email to

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