Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] Documentation on (A) Create array parameter



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