Very nice!

One should add a 'shift', though, so that any predefined values in 'dest'
wouldn't get duplicated by a call to that function.

Janis

> Date: Tue, 6 Mar 2012 09:57:44 -0500
> From: [email protected]
> To: [email protected]; [email protected]
> Subject: Re: Re: [ast-users] Is there a way to pass a variable number of      
> namerefs to a function?
> CC: 
> 
> cc: [email protected]
> Subject: Re: Re: [ast-users] Is there a way to pass a variable number of 
> namerefs  to a function?
> --------
> 
> Here is a complete program that copies any number of source arrays into the 
> destination passing the array names as references.
> 
> function copy_args #  dest src ...
> {
>       nameref newarr=$1 arr
>       for arr in "$@"
>       do      newarr+=(${arr[@]})
>       done
> }
> 
> a=(x y z)
> b=(a b c)
> typeset -a c
> copy_args c a b
> typeset -p c
> 
> David Korn
> [email protected]
> _______________________________________________
> ast-users mailing list
> [email protected]
> https://mailman.research.att.com/mailman/listinfo/ast-users
                                          
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to