From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: PATCH: [key]=value syntax, work in progress
Date: Thu, 14 Sep 2017 21:38:46 +0100 [thread overview]
Message-ID: <20170914213846.157fc1e2@ntlworld.com> (raw)
In-Reply-To: <20170913204108.7a55fdd6@ntlworld.com>
typeset -p update and other tweaks Daniel wanted (feel free to make your
own doc patches rather than getting me to do the work :-)). Does look
clearer this way.
pws
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index a61738f..d5e5838 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -1025,9 +1025,10 @@ ifnzman(noderef(Filename Expansion))\
ifzman(the section FILENAME EXPANSION below).
)
item(tt(e))(
-Perform em(parameter expansion), em(command substitution) and
-em(arithmetic expansion) on the result. Such expansions can be
-nested but too deep recursion may have unpredictable effects.
+Perform single word shell expansions, namely em(parameter expansion),
+em(command substitution) and em(arithmetic expansion), on the
+result. Such expansions can be nested but too deep recursion may have
+unpredictable effects.
)
item(tt(f))(
Split the result of the expansion at newlines. This is a shorthand
diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index 33e9fd6..2534d1c 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -102,13 +102,16 @@ may be in any order. Note that this syntax is strict: tt([) and tt(]=) must
not be quoted, while var(key) may not consist of the unquoted string
tt(]=), but is otherwise treated as a simple string. Furthermore, all
elements must match this form or an error is generated; likewise, if the
-first entry does not match this form any later entry that does is taken
+first entry does not match this form, any later entry that does is taken
as a simple value rather than a key / value pair. The enhanced forms of
subscript expression that may be used when directly subscripting a
variable name, described in the section Array Subscripts below, are not
available. Both var(key) and var(value) undergo all forms of expansion
-allowed for single word substitutions (this does not include filename
-generation).
+allowed for single word shell expansions (this does not include filename
+generation); these are as performed by the parameter expansion flag
+tt(LPAR()e+RPAR()) as described in
+ifzman(zmanref(zshparam))\
+ifnzman(nodref(Parameter Expansion)).
If no parameter var(name) exists, an ordinary array parameter is created.
If the parameter var(name) exists and is a scalar, it is replaced by a new
diff --git a/Src/params.c b/Src/params.c
index e0aaaf6..d628ddf 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -5564,9 +5564,7 @@ printparamvalue(Param p, int printflags)
{
char *t, **u;
- if (printflags & PRINT_KV_PAIR)
- putchar(' ');
- else
+ if (!(printflags & PRINT_KV_PAIR))
putchar('=');
/* How the value is displayed depends *
@@ -5721,7 +5719,11 @@ printparamnode(HashNode hn, int printflags)
zputs(p->node.nam, stdout);
putchar('\n');
} else {
+ if (printflags & PRINT_KV_PAIR)
+ putchar('[');
quotedzputs(p->node.nam, stdout);
+ if (printflags & PRINT_KV_PAIR)
+ printf("]=");
printparamvalue(p, printflags);
}
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst
index ae21804..7923ae3 100644
--- a/Test/B02typeset.ztst
+++ b/Test/B02typeset.ztst
@@ -763,6 +763,7 @@
for key in ${(ok)keyvalhash}; do
print -l $key $keyvalhash[$key]
done
+ typeset -p keyvalhash
0:Substitution in [key]=val syntax
>*
>?not_globbed?
@@ -776,3 +777,4 @@
>another value
>the key
>the value
+>typeset -A keyvalhash=( ['*']='?not_globbed?' ['another key']='another value' ['the key']='the value' )
diff --git a/Test/V10private.ztst b/Test/V10private.ztst
index 78ecd48..880784e 100644
--- a/Test/V10private.ztst
+++ b/Test/V10private.ztst
@@ -123,7 +123,7 @@
print ${(kv)hash_test}
0:private hides value from surrounding scope in nested scope
>typeset -a hash_test=( top level )
->typeset -A hash_test=( in function )
+>typeset -A hash_test=( [in]=function )
>typeset -g -a hash_test=( top level )
>array-local top level
>top level
next prev parent reply other threads:[~2017-09-14 20:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-11 20:51 Peter Stephenson
2017-09-11 20:56 ` Peter Stephenson
2017-09-12 20:25 ` Peter Stephenson
2017-09-12 20:28 ` Peter Stephenson
2017-09-13 7:13 ` Bart Schaefer
2017-09-13 8:53 ` Peter Stephenson
2017-09-13 16:44 ` Bart Schaefer
2017-09-14 20:48 ` Peter Stephenson
2017-09-19 1:13 ` Bart Schaefer
2017-09-13 9:14 ` Oliver Kiddle
2017-09-13 19:41 ` Peter Stephenson
2017-09-14 7:03 ` Daniel Shahaf
2017-09-14 20:38 ` Peter Stephenson [this message]
2017-09-16 10:30 ` Daniel Shahaf
2017-09-14 6:54 ` 'typeset -p' of assocs (was: Re: PATCH: [key]=value syntax, work in progress) Daniel Shahaf
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=20170914213846.157fc1e2@ntlworld.com \
--to=p.w.stephenson@ntlworld.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).