zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: more substitution documentation
@ 1999-03-18  9:16 Peter Stephenson
  1999-03-18 15:23 ` Final touch? " Andrej Borsenkow
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Stephenson @ 1999-03-18  9:16 UTC (permalink / raw)
  To: Zsh hackers list

This is more less my explanation of Andrej's other query yesterday, which I
think I now understand.  If anyone wants to suggest rearranging the
information in this part of the manual, please go ahead and say where you
want it to appear.

--- Doc/Zsh/expn.yo.js	Wed Mar 17 11:51:19 1999
+++ Doc/Zsh/expn.yo	Thu Mar 18 10:11:47 1999
@@ -729,6 +729,21 @@
 )
 enditem()
 
+Any joining and splitting of words which is necessary occurs in that order,
+and after any other substitutions performed on the value at that level of
+substitution; this includes implicit splitting on the characters in
+tt($IFS) when the option tt(SH_WORD_SPLIT) is set.  In particular, when
+splitting is requested on an array value it is first joined, either using
+any string given by the tt(LPAR()j)tt(RPAR()) flag, or a space if there is
+none.  So if tt($foo) contains the array tt(LPAR()ax1 bx1)tt(RPAR()), then
+tt(${(s/x/)foo}) produces the words `tt(a)', `tt(1 b)' and `tt(1)', while
+tt(${(j/x/s/x/)foo}) produces `tt(a)', `tt(1)', `tt(b)' and `tt(1)'.  As
+substituion occurs before either joining or splitting, the operation
+tt(${(s/x/)foo%%1*}) first generates the modified array tt(LPAR()ax
+bx)tt(RPAR()), which is joined to give tt("ax bx"), and then split to give
+`tt(a)', `tt( b)' and `'.  The final empty string will then be elided, as
+it is not in double quotes.
+
 texinode(Command Substitution)(Arithmetic Expansion)(Parameter Expansion)(Expansion)
 sect(Command Substitution)
 cindex(command substitution)

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-03-18 15:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-18  9:16 PATCH: more substitution documentation Peter Stephenson
1999-03-18 15:23 ` Final touch? " Andrej Borsenkow

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).