Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: read/write associative array from/to file
- X-seq: zsh-users 16694
- From: Wayne Davison <wayne@xxxxxxxxxxxxxxx>
- To: Jérémie Roquet <arkanosis@xxxxxxxxx>
- Subject: Re: read/write associative array from/to file
- Date: Tue, 3 Jan 2012 09:02:39 -0800
- Cc: Thomas Gstädtner <thomas@xxxxxxxxxxxxxx>, zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed; d=thedavisons.net; h= mime-version:in-reply-to:references:date:message-id:subject:from :to:cc:content-type; s=thedavisons.net; bh=7zqi8OQtXkj1kchsOv8+K tm/TJM=; b=Qv4DiSkt+Nay6+3cFvSS/Nmgr1ei9EFDAluXQS1fHGnqJ1uAI487w uiqihv8BTMBenk8Z7rIQ0uU/MWgFhVsera1lz4DBd65kqfXy1545kOU1op1Ctc3A u5Mh14nGmIs8h/lP6qrSIKg9tRrGvkMzqHGaq3FPN4rYzMt8I6NF9Q=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=thedavisons.net; h=mime-version :in-reply-to:references:date:message-id:subject:from:to:cc: content-type; q=dns; s=thedavisons.net; b=fibpnmjHXPqu2v93um62di +QWxt3UDxpcYt1vIlumXGogh2UgxoyVCzJeCnQmwtKz1WYJns6iludMbMeL3yc+y 9ulU4m+VYpqiFSFnKmp9Hv+jqDrnncmsaY2O5OErsLtvDG7nroPjj3w88fldSITM mF7xmXlJHIx5rKiwyfNpo=
- In-reply-to: <CAFOazAP6U0sJEGs6j+BBNashbaqsjB0Ni4iGE0ziq6Ks68njPg@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <4F0263FB.2000202@gstaedtner.net> <CAFOazAP6U0sJEGs6j+BBNashbaqsjB0Ni4iGE0ziq6Ks68njPg@mail.gmail.com>
On Tue, Jan 3, 2012 at 1:40 AM, Jérémie Roquet <arkanosis@xxxxxxxxx> wrote:
> echo "myArray=(${(kv)myArray})" >| $db
>
That works if there are no spaces or special characters involved. You
could change that line to remove the double quotes and add (q) or (q-) to
the expansion, and it would handle those:
typeset -A myArray
myArray=(
foo 1\ is\ the\ loneliest\ number
bar 42\ isn\'t\ really\ the\ ultimate\ answer
)
echo myArray=\(${(kvq-)myArray}\) >/tmp/myArray
typeset -A myArray
source /tmp/myArray
echo ${(q-)myArray[bar]}
..wayne..
Messages sorted by:
Reverse Date,
Date,
Thread,
Author