From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: get keys of an associative array?
Date: Mon, 27 Mar 2017 09:36:55 +0100 [thread overview]
Message-ID: <20170327093655.5186c8c3@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20170326220628.GB13200@trex.cs.ovgu.de>
On Mon, 27 Mar 2017 00:06:28 +0200
Jens Elkner <jel+zsh@cs.uni-magdeburg.de> wrote:
> On Sun, Mar 26, 2017 at 01:03:31PM -0700, Bart Schaefer wrote:
> > On Mar 26, 2017 12:41 PM, "Peter Stephenson" <p.w.stephenson@ntlworld.com>
> > wrote:
> >
> > You need "${(k)A[@]}" in ksh mode, but I'm not sure why the (@) flag
> > doesn't do the trick.
> >
> > The @ flag only makes things that are already arrays remain arrays in
> > contexts where they would otherwise be joined. In ksharrays context, ${A}
> > is a scalar.
>
> You mean man page section for the k flag needs enhancements? At least A
> is explictly declared as an associative array, so I would expect, that
> "${(k)A}" should work as well ...
I'm not sure how general an update this ought to be...
pws
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index e049aa5..dc6c494 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -1049,7 +1049,9 @@ If var(name) refers to an associative array, substitute the em(keys)
(element names) rather than the values of the elements. Used with
subscripts (including ordinary arrays), force indices or keys to be
substituted even if the subscript form refers to values. However,
-this flag may not be combined with subscript ranges.
+this flag may not be combined with subscript ranges. With the
+tt(KSH_ARRAYS) option a subscript `tt([*)' or `tt([@])' is needed
+to operate on the whole array, as usual.
)
item(tt(L))(
Convert all letters in the result to lower case.
next prev parent reply other threads:[~2017-03-27 8:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-26 19:18 Jens Elkner
2017-03-26 19:34 ` Peter Stephenson
2017-03-26 20:03 ` Bart Schaefer
2017-03-26 22:06 ` Jens Elkner
2017-03-27 8:36 ` Peter Stephenson [this message]
2017-03-26 21:55 ` Jens Elkner
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=20170327093655.5186c8c3@pwslap01u.europe.root.pri \
--to=p.stephenson@samsung.com \
--cc=zsh-workers@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).