On 4/28/09, Bernd Eggink <[email protected]> wrote:
> ольга крыжановская schrieb:
>
> > The following one line example should print "cc bb aa" but yields to a
> > syntax error:
> >
> > ksh93 -c 'typeset -a a=( [0]="aa" [1]="bb" [2]="cc" ) ; typeset -m
> > 'j=a[0]' ; typeset -m 'a[0]=a[1]' ; typeset -m 'a[1]=j' ; print
> > "$...@]}"'
> > ksh93[1]: typeset: : invalid variable name
> >
> > Is this a bug or am I doing something wrong?
> >
>
>  The problem is the quoting; the word after -c is terminated by the leading
> apostrophe in 'j=a[0]'.
>
>  However, there is an additional problem which looks like a bug in ksh93t:
>
>   a=(11 22)
>   typeset -m x=a[i]
>
>  This assigns a[0] to x, irrespective of the index i, and then unsets the
> complete array a.

Surprise, surprise, it works with associative arrays:
$ ksh93  -x -c 'typeset -A a=( [0]="aa" [1]="bb" [2]="cc" ) ; typeset
-m "j=a[0]" ; typeset -m "a[0]=a[1]" ; typeset -m "a[1]=j" ; print
"$...@]}"'
+ a[0]=aa
+ a[1]=bb
+ a[2]=cc
+ typeset -A a
+ typeset -m j='a[0]'
+ typeset -m 'a[0]=a[1]'
+ typeset -m 'a[1]=j'
+ print bb aa cc
bb aa cc

Can someone explain this?
-- 
      ,   _                                    _   ,
     { \/`o;====-    Olga Kryzhanovska   -====;o`\/ }
.----'-/`-/     [email protected]   \-`\-'----.
 `'-..-| /     Solaris/BSD//C/C++ programmer   \ |-..-'`
      /\/\                                     /\/\
      `--`                                      `--`

_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to