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

[PATCH] [doc] & not recognized in :s/LHS/&RHS with HIST_SUBST_PATTERN



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



Messages sorted by: Reverse Date, Date, Thread, Author