Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: indirect assignment to array
On 4/16/20, Pier Paolo Grassi <pierpaolog@xxxxxxxxx> wrote:
> Hello, I'm trying to assign the content of an array to another which name
> is contained in a variable
> What I tried:
>
> varname=newarray
> typeset -a array=(1 2 3)
> typeset -a $varname=($array)
>
> but I get an
> zsh: bad pattern: newarray=(1
>
> are there other methods to do indirect assignment that allow me to do this?
: ${(PA)varname::=$array}
(leave out the A for scalar assignment, and use AA for assoc arrays).
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author