On Tue, Mar 13, 2012 at 23:09, David Korn <[email protected]> wrote:

> cc:  [email protected]
> Subject: Re: [ast-users] [ksh93] `alias not found' for `arr=( a b )'
> --------
>
> > $ echo ${.sh.version}
> > Version JMP 93u+ 2012-02-14
> > $ alias a=alias
> > $ alias b='cd -'
> > $ typeset -a arr=( a b )
> > $ arr=( a b )
> > b: alias not found    <-- Bug? Why are aiases involved here?
> > $ arr=( b a )
> > $
> >
> > (attachment  1     7/334                text/html "1.att")
> >
>
> The form
>        var=(...)
> is a generic compound variable assignment.  It is use for
> indexed arrays, associative arrays, and for compound variables.
> However, in some cases this is ambiguous.
>
>        var=()
> is this an empty compound variable, an empty indexed array, or
> an empty associative array.  By default, ambiguities lean towards
> selection the compound variable.
>
> Another example,
>        var=(integer x=3)
> This will be treated as a compound assignment defining x=3.  However,
> in order for this to work, the alias integer must be recognized.
> Therefore, by default, the first work is alias expanded.
>
> Therefore, it is best to explicity specify which you want.
>
>        typeset -a var=(integer x=3)
>

But this surprised me again:

$ typeset -a arr=(name=clarkw from=beijing)
$ typeset -p arr
typeset -a arr=((from=beijing;name=clarkw))
$ echo ${!arr[@]}
0
$ typeset -p arr[0]
typeset -C arr[0]=(from=beijing;name=clarkw)
$


> will define an indexed array with two elements, integer and x=3.  The
> first argument will not be checked for aliases.
>        typeset -a var=([3]=abc [foo]=def)
> will define an indexed array with elements 3 and the arithmetic value
> of foo $((foo)).
>
> Use
>        typeset -A for associative array definition.
>
> Use
>        typeset -C for compound assignment.
>
>
>
> David Korn
> [email protected]
>
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to