From: Sebastian Gniazdowski <psprint2@fastmail.com>
To: zsh-workers@zsh.org
Subject: [PATCH] Documentation on (A) Create array parameter
Date: Wed, 22 Feb 2017 03:40:13 -0800 [thread overview]
Message-ID: <1487763613.2941773.889107120.2750751A@webmail.messagingengine.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1231 bytes --]
Hello,
(A) completion and documentation suggest straight creation:
A Create an array parameter with `${...=...}', `${...:=...}'
or `${...::=...}'. If this flag is
repeated (as in `AA'), create an associative array
parameter. Assignment is made before sorting
or padding; if field splitting is active, the word part is
split before assignment. The name
part may be a subscripted range for ordinary arrays;
the word part must be converted to an
array, for example by using `${(AA)=name=...}' to activate
field splitting, when creating an
associative array.
This test:
% typeset -a overwrite_me=( 1 ); () { var_name="overwrite_me"; :
${(PA)var_name::=}; }; echo $overwrite_me"."${(t)overwrite_me}
.array
% () { local -a overwrite_me=( 1 ); () { var_name="overwrite_me"; :
${(PA)var_name::=}; }; echo $overwrite_me"."${(t)overwrite_me} }
.array-local
shows that parameter is reused if it exists, even if it exists on lower
scoping level. That's useful when coding, the patch adds one sentence
that clarifies this.
--
Sebastian Gniazdowski
psprint2@fastmail.com
[-- Attachment #2: A_create_array.diff --]
[-- Type: text/plain, Size: 615 bytes --]
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index cf4f69e..386db08 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -964,6 +964,8 @@ assignment. The var(name) part may be a subscripted range for
ordinary arrays; the var(word) part em(must) be converted to
an array, for example by using `tt(${(AA)=)var(name)tt(=)...tt(})'
to activate field splitting, when creating an associative array.
+If the array parameter whose creation is requested already exists,
+it is reused, even when it exists at lower scoping level.
)
item(tt(a))(
Sort in array index order; when combined with `tt(O)' sort in reverse
next reply other threads:[~2017-02-22 11:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-22 11:40 Sebastian Gniazdowski [this message]
2017-02-22 19:58 ` Bart Schaefer
2017-02-22 20:47 ` Sebastian Gniazdowski
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=1487763613.2941773.889107120.2750751A@webmail.messagingengine.com \
--to=psprint2@fastmail.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).