Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: get keys of an associative array?
On Mon, 27 Mar 2017 00:06:28 +0200
Jens Elkner <jel+zsh@xxxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxx>
> > 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author