Roland Mainz wrote:
> Is there a way to return a compound variable value from a function
> without dismanteling each single value first (which would be very
> painfull in the case when the compound variable has hundreds or
> thousands of members which itself are compound variables (see
> http://opensolaris.pastebin.ca/raw/683236 for an example)) ?
>
> I've tried the following example but it doesn't really work:
> -- snip --
> function g
> {
> typeset x=(float x=1 y=2)
> print $x
> }
>
> typeset l=$(g)
>
> print "${l.x}"
> -- snip --
>
> The variable "l.x" is empty in this case.
It seems one possible solution may be to use "eval", e.g $ (function g {
typeset x=( typeset -lE x=1 y=2 ) ; print -- "$x" ; } ; eval "typeset
l=$(g)" ; print ${l.x}) # ... but I wish the use of "eval" could be
avoided (at least it copies the returned string twice instead of one
time and 2nd
http://mail.opensolaris.org/pipermail/shell-discuss/2007-June/000993.html
says "eval" should be avoided unless there is no other option (and I'm
not sure whether this is the case...)) ...
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 7950090
(;O/ \/ \O;)