Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] [doc] & not recognized in :s/LHS/&RHS with HIST_SUBST_PATTERN
- X-seq: zsh-workers 38412
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: [PATCH] [doc] & not recognized in :s/LHS/&RHS with HIST_SUBST_PATTERN
- Date: Fri, 6 May 2016 13:56:49 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-disposition:user-agent; bh=EQP/kuU/NwvLeBveOTLBxt1pII/lpE/MD0rHJ0/S2fc=; b=EEn/MVxytgNrDGv36z16kM0ck2c5LYFRWu0g8fKr2D59wcd7nYC49pTOYTreEKOJHy MBX8p2XjpnsZggYuYFHneQjgQFaEVNPg9dFG3POrwew89r7IKjS7eXIpmQ8sR3uNEk+2 oz68trosftccPWNkJQLAQ/gFCjv+IsJiOsurJaPF1o6vv4gyzC8/Bjyf3FWccGuGQAkl EngjitQwFAnQwo8Xa4k2HMDz5riQ3ygBSh73BydPaLyyN+XaLs1ueb/SkIbpgFFP9ubS nJSeLjfuXr2zT3DgZ/kZEpxQHPiWlZNW9aew0QdmC+IGIdG2d5PPO3lxOdKHXzEPMmAA LQSg==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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