Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: copying an array



On Aug 5,  6:44am, Dominik Vogt wrote:
>
> typeset -g -a G
> G=("a b c" d e)
> copy_array () {
> 	typeset -g -a "$1"
> 	# how can this be done?
> 	$1="($G[@])"
> }

You probably don't need the function at all if this is the only thing it
is doing:

	set -A "$1" "$G[@]"

The only reason for the "typeset -g" would be if there is a local array
in scope whose name is the same as the value of $1.  Otherwise "set -A"
will create the global array for you.



Messages sorted by: Reverse Date, Date, Thread, Author