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

Re: clone an associative array?



On Fri, Aug 19, 2005 at 03:24:52PM +0100, Peter Stephenson wrote:
[...]
> typeset -A counterfeit
> counterfeit=(${(kv)homemade})
> 
> Make sure you don't have the option SH_WORD_SPLIT set.  (This is a
> classic example of why it's a good idea to get used to doing without it.)
[...]

Hmmm,

~$ typeset -A a b
~$ a=(a 1 b '' c 2)
~$ echo "$a[b]"

~$ b=(${(kv)a})
zsh: bad set of key/value pairs for associative array

Hence, the b=("${(@kv)a}") that would also work with
SH_WORD_SPLIT.

-- 
Stephane



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