From: Wayne Davison <wayne@thedavisons.net>
To: "Jérémie Roquet" <arkanosis@gmail.com>
Cc: "Thomas Gstädtner" <thomas@gstaedtner.net>, zsh-users@zsh.org
Subject: Re: read/write associative array from/to file
Date: Tue, 3 Jan 2012 09:02:39 -0800 [thread overview]
Message-ID: <CAHSx_Stt5ZR9ez=Sb+kbKFtsb-goSeF+XmkF=hVPxrKw+9R11w@mail.gmail.com> (raw)
In-Reply-To: <CAFOazAP6U0sJEGs6j+BBNashbaqsjB0Ni4iGE0ziq6Ks68njPg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 567 bytes --]
On Tue, Jan 3, 2012 at 1:40 AM, Jérémie Roquet <arkanosis@gmail.com> 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..
next prev parent reply other threads:[~2012-01-03 17:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-03 2:12 Thomas Gstädtner
2012-01-03 9:40 ` Jérémie Roquet
2012-01-03 17:02 ` Wayne Davison [this message]
2012-01-05 5:20 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHSx_Stt5ZR9ez=Sb+kbKFtsb-goSeF+XmkF=hVPxrKw+9R11w@mail.gmail.com' \
--to=wayne@thedavisons.net \
--cc=arkanosis@gmail.com \
--cc=thomas@gstaedtner.net \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).