* [PATCH] [doc] & not recognized in :s/LHS/&RHS with HIST_SUBST_PATTERN
@ 2016-05-06 12:56 Stephane Chazelas
0 siblings, 0 replies; only message in thread
From: Stephane Chazelas @ 2016-05-06 12:56 UTC (permalink / raw)
To: Zsh hackers list
It looks like
${var:s/foo/...&}
(or in glob qualifiers or history expansion)
doesn't work when HIST_SUBST_PATTERN is set.
This patch just makes a note of it in the doc.
One can use ${var:s/(#m)foo/...$MATCH} though.
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index c6e7b6f..851b837 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -301,25 +301,26 @@ item(tt(x))(
Like tt(q), but break into words at whitespace. Does not work with
parameter expansion.
)
enditem()
The tt(s/)var(l)tt(/)var(r)tt(/) substitution works as follows. By
default the left-hand side of substitutions are not patterns, but
character strings. Any character can be used as the delimiter in place
-of `tt(/)'. A backslash quotes the delimiter character. The character
-`tt(&)', in the right-hand-side var(r), is replaced by the text from the
-left-hand-side var(l). The `tt(&)' can be quoted with a backslash. A
-null var(l) uses the previous string either from the previous var(l) or
-from the contextual scan string var(s) from `tt(!?)var(s)'. You can
-omit the rightmost delimiter if a newline immediately follows var(r);
-the rightmost `tt(?)' in a context scan can similarly be omitted. Note
-the same record of the last var(l) and var(r) is maintained across all
-forms of expansion.
+of `tt(/)'. A backslash quotes the delimiter character. Unless the
+tt(HIST_SUBST_PATTERN) option is set, the character `tt(&)', in the
+right-hand-side var(r), is replaced by the text from the left-hand-side
+var(l). The `tt(&)' can be quoted with a backslash. A null var(l) uses
+the previous string either from the previous var(l) or from the
+contextual scan string var(s) from `tt(!?)var(s)'. You can omit the
+rightmost delimiter if a newline immediately follows var(r); the
+rightmost `tt(?)' in a context scan can similarly be omitted. Note the
+same record of the last var(l) and var(r) is maintained across all forms
+of expansion.
Note that if a `tt(&)' is used within glob qualifiers an extra backslash
is needed as a tt(&) is a special character in this case.
Also note that the order of expansions affects the interpretation of
var(l) and var(r). When used in a history expansion, which occurs before
any other expansions, var(l) and var(r) are treated as literal strings
(except as explained for tt(HIST_SUBST_PATTERN) below). When used in
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-05-06 19:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-06 12:56 [PATCH] [doc] & not recognized in :s/LHS/&RHS with HIST_SUBST_PATTERN Stephane Chazelas
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).