On Monday, May 26, 2014 01:15:55 PM Henk Langeveld wrote:
> My observation below...
> 
> On 05/26/2014 09:10 AM, Dan Douglas wrote:> Hi,
> >
> > When I increment an uninitialized element of an indexed or associative array
> > from within an arithmetic context, there is no effect in the latest alpha. 
> > It
> > worked in ksh93u. It applies only to arithmetic assignments, but 
> > incrementing
> > via simple assignment works fine.
> >
> > Can anyone reproduce this regression?
> >
> >       $ ksh -c 'print -v .sh.version'
> >       Version AIJM 93v- 2014-05-09
> >
> >       # Increment from math context broken.
> >       $ ksh -c 'integer i; integer -a arr; ((i++, arr[3]++)); typeset -p 
> > arr i'
> >      typeset -a -l -i arr=()
> >      typeset -l -i i=1
> 
> There are two things at work here.
> 
> One: we're working with unitialised variables. What do the standards 
> actually say about this?  (I will be looking this up).

POSIX doesn't say anything about the integer attribute and doesn't require the
pre/post increment operators. However:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html#tag_17_01_02_01

"All variables shall be initialized to zero if they are not otherwise assigned
by the input to the application."

Not to mention consistency with the rest of the language and all the other
implementations.

> Two: The regression appears to be constrained to 'typeset -p', which I'm 
> unlikely to use in a script.

Interesting. I don't usually use it in scripts either but it's invaluable for
testing/debugging IMO. print -C (or printf '%#B') is also affected (which is
much more useful in scripts):

        $ ksh <<\EOF
        > integer -a arr
        > ((arr[3]++))
        > printf "<%s> " "$(print -v arr[3])" "$(print -C arr)" "$(typeset -p 
arr)" "${arr[3]}" $((arr[3]))
        > echo
        > EOF
        <1> <> <typeset -a -l -i arr=()> <1> <1>

-- 
Dan Douglas

_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to