Jan Marek
Jan Marek

Reputation: 11200

How make array in zsh with name derived from variable

I would like make a associative array and as values I would like to have array with name like keyv.

For example:

#!/bin/zsh

$key='key'

typeset -A associative_array
typeset -a "${(p)key}v"
"${(p)key}v"=( value1 )
"${(p)key}v"+=( value2 )
associative_array[${key}]="${(p)key}v"

But I've got an error:

./test.sh:7: unknown file attribute:

which is on the line: "${(p)key}v"=( value1 )

Is there a way to do it?

Many thanks for advices.

Upvotes: 0

Views: 38

Answers (0)

Related Questions