zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: a couple of expansion notes
@ 2006-09-12 15:18 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2006-09-12 15:18 UTC (permalink / raw)
  To: Zsh hackers list

This is supposed to document a couple of issues which turned up
recently.

Index: Doc/Zsh/expn.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v
retrieving revision 1.67
diff -u -r1.67 expn.yo
--- Doc/Zsh/expn.yo	28 Jun 2006 14:34:27 -0000	1.67
+++ Doc/Zsh/expn.yo	12 Sep 2006 15:16:20 -0000
@@ -608,6 +608,14 @@
 pattern anywhere that is possible, such as in filename expansion and
 filename generation and pattern-matching contexts like the right
 hand side of the `tt(=)' and `tt(!=)' operators in conditions.
+
+In nested substitutions, note that the effect of the tt(~) applies to the
+result of the current level of substitution.  A surrounding pattern
+operation on the result may cancel it.  Hence, for example, if the
+parameter tt(foo) is set to tt(*), tt(${~foo//\*/*.c}) is substituted by
+the pattern tt(*.c), which may be expanded by filename generation, but
+tt(${${~foo}//\*/*.c}) substitutes to the string tt(*.c), which will not
+be further expanded.
 )
 enditem()
 
@@ -950,6 +958,16 @@
 Note that, unless the `tt((P))' flag is present, the flags and any subscripts
 apply directly to the value of the nested substitution; for example, the
 expansion tt(${${foo}}) behaves exactly the same as tt(${foo}).
+
+At each nested level of substitution, the substituted words undergo all
+forms of single-word substitution (i.e. not filename generation), including
+command substitution, arithmetic expansion and filename expansion
+(i.e. leading tt(~) and tt(=)).  Thus, for example, tt(${${:-=cat}:h})
+expands to the directory where the tt(cat) program resides.  (Explanation:
+the internal substitution has no parameter but a default value tt(=cat),
+which is expanded by filename expansion to a full path; the outer
+substitution then applies the modifier tt(:h) and takes the directory part
+of the path.)
 )
 item(tt(2.) em(Parameter Subscripting))(
 If the value is a raw parameter reference with a subscript, such as


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-09-12 15:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-12 15:18 PATCH: a couple of expansion notes Peter Stephenson

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