Thanks! I was afraid I had to resort to eval. By the way, I was trying to create an helper function like this: debugvar(){ typeset -g $1 typeset +m $1 typeset $1 } but I found out from the manual that -g "it has no effect when listing existing parameters" is there a way to use typeset from functions to print out the definition of global variables? thanks again Pier Paolo Grassi Il giorno gio 16 apr 2020 alle ore 01:13 Mikael Magnusson ha scritto: > On 4/16/20, Pier Paolo Grassi 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 >