cc: [email protected]
Subject: Re: [ast-users] [ksh93] typeset -a arr=([k1]=v1 [k2]=v2) bug?
--------
>
> $ ksh --version
> version sh (AT&T Research) 93u 2011-02-08
> $ cat foo.sh
> typeset -a arr
> typeset -i k1=0
> typeset -i k2=1
> arr=( [k1]=v1 [k2]=v2 )
> echo ${!arr[@]}
> $ ksh foo.sh
> k1 k2 <-- Bug? Should output: 0 1
> $
>
>
This is not a bug, the line
arr=( [k1]=v1 [k2]=v2 )
first unsets arr and then does the assignment. The assignment creates
an associative array.
However, if you had done
typeset -a arr=( [k1]=v1 [k2]=v2 )
then this would have forced arr to be an indexed array and then the output
would be 0 1,
David Korn
[email protected]
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users