summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-10-27 10:58:39 +0000
committerPeter Stephenson <pws@zsh.org>2015-10-27 10:58:39 +0000
commit63fd71f171e9d282985ba24e5f3ee2507bce6f47 (patch)
treea53bccf46abc1478ef551b7eea095c0761a8d923
parentd45a68c5463224f43721371fb7bd4cbc24e62874 (diff)
downloadzsh-63fd71f171e9d282985ba24e5f3ee2507bce6f47.tar.gz
zsh-63fd71f171e9d282985ba24e5f3ee2507bce6f47.tar.xz
zsh-63fd71f171e9d282985ba24e5f3ee2507bce6f47.zip
36977: note about difficulties of pattern repetitions
-rw-r--r--ChangeLog3
-rw-r--r--Doc/Zsh/expn.yo10
2 files changed, 13 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 846b57ef7..b64f785f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-10-27  Peter Stephenson  <p.stephenson@samsung.com>
 
+	* 36977: Doc/Zsh/expn.yo: note about complications of pattern
+	repetitions (#cN).
+
 	* 36974: Src/Modules/zftp.c, Src/Zle/complist.c,
 	Src/Zle/computil.c, Src/Zle/zle_thingy.c, Src/parse.c: fix empty
 	argument lists.
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index 5ea8610f2..49a0f0d53 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -2192,6 +2192,16 @@ inclusive.  The form tt(LPAR()#c)var(N)tt(RPAR()) requires exactly tt(N)
 matches; tt(LPAR()#c,)var(M)tt(RPAR()) is equivalent to specifying var(N)
 as 0; tt(LPAR()#c)var(N)tt(,RPAR()) specifies that there is no maximum
 limit on the number of matches.
+
+Note that if the previous group of characters contains wildcards,
+results can be unpredictable to the point of being logically incorrect.
+It is recommended that the pattern be trimmed to match the minimum
+possible.  For example, to match a string of the form `tt(1_2_3_)', use
+a pattern of the form `tt(LPAR()[[:digit:]]##_+RPAR()LPAR()#c3+RPAR())', not
+`tt(LPAR()*_+RPAR()LPAR()#c3+RPAR())'.  This arises from the
+complicated interaction between attempts to match a number of
+repetitions of the whole pattern and attempts to match the wildcard
+`tt(*)'.
 )
 vindex(MATCH)
 vindex(MBEGIN)