Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Documentation on (A) Create array parameter
- X-seq: zsh-workers 40615
- From: Sebastian Gniazdowski <psprint2@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] Documentation on (A) Create array parameter
- Date: Wed, 22 Feb 2017 03:40:13 -0800
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= mesmtp; bh=lBvwZUMGhpcSbjHmmuJYyBg0msQ=; b=kt8TwWWKmjtWB8vvP20zU MJHHJI6w0DXElFSK+81QBO9kzix3lvwZ8OtsRWiG2g66HoMY5gj9GMHGnCW/jxDh 1Zku2vmY5fw1fyHzCnIglCn1iHJ1hVTxoGHlWfnBLJ/P3O4/OvK6xK4F0eGvft1O ubCZFiK07xR6vUTUUCdYVA=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=smtpout; bh=lBvwZUMGhpcSbjHmmuJYyBg0m sQ=; b=hU1oO+gfM3en3u4qvIkawLIsm2db/E75w/Cm0d7Pz9UJEjOyu+6UvyvuV 6bUpHnGppkoa5aDHk6QKGHSbAqmxVp6xjXKMiAILhWP2O8+sz8pmhVlipkNBVNC0 tVaVX/m4Ojuqzq1/gzkrlTmqNpWyWWGZMf32kCqvIJmkcvJrPw=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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@xxxxxxxxxxxx
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author