cc: [EMAIL PROTECTED]
Subject: Re: [ast-developers] Arrays in structured variables
--------
> I'm having problems extracting an array component from a structured
> variable. Is that supposed to work anyway? Here is an example:
>
> el0=(typeset name="base"; typeset -a children)
> el1=(typeset text=one)
> el2=(typeset text=two)
> el0.children=($el1 $el2)
> print "child0 = ${el0.children[0]}"
>
> The output looks somewhat strange:
>
> child0 = (
>
> The output of 'print $el0', however, is correct:
>
> ( typeset -a children=( '(' text\=one ')' '(' text\=two ')' )
> name=base )
>
> and the example works if a structured variable is used in place of the
> array, so I think it's bug specific to array components.
>
> Regards,
> Bernd
>
> --
> Bernd Eggink
> [EMAIL PROTECTED]
> http://sudrala.de
I think that the problem is that the ( and ) are only recognized during
parsing, not during expansion.
That is why you need to do
eval bar="$foo"
to copy compound variable foo into bar rather than just
bar=$foo
Thus, the line
el0.children=($el1 $el2)
does not do what you expect. I suspect that you wanted to do
el0.children=( (typeset text=one) (typeset text=two) )
which you could do as
eval el0.children=\( "$el0" "$el2" \)
If this is not what you intended, let me know.
David Korn
[EMAIL PROTECTED]
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers