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

[PATCH] documentation update =~ regex MATCH



The patch below should update the docs to make it clearer that no
variables are touched if regex matches fail.

yodl is currently segfaulting for me, so I can't test a make from them.
It looks like simple text changes which Can't Possibly Go Wrong, though,
so unless someone shouts I'll commit this anyway in a day or so.

Index: Doc/Zsh/cond.yo
===================================================================
RCS file: /home/cvsroot/zsh/Doc/Zsh/cond.yo,v
retrieving revision 1.5
diff -a -u -p -r1.5 cond.yo
--- Doc/Zsh/cond.yo	13 May 2007 20:18:28 -0000	1.5
+++ Doc/Zsh/cond.yo	15 Jan 2009 00:48:30 -0000
@@ -115,6 +115,8 @@ var(regexp).  If the option tt(RE_MATCH_
 var(regexp) is tested as a PCRE regular expression using
 the tt(zsh/pcre) module, else it is tested as a POSIX
 extended regular expression using the tt(zsh/regex) module.
+Upon successful match, some variables will be updated; no variables
+are changed if the matching fails.
 If the option tt(BASH_REMATCH) is set the array
 tt(BASH_REMATCH) is set to the substring that matched the pattern
 followed by the substrings that matched parenthesised
Index: Doc/Zsh/mod_pcre.yo
===================================================================
RCS file: /home/cvsroot/zsh/Doc/Zsh/mod_pcre.yo,v
retrieving revision 1.6
diff -a -u -p -r1.6 mod_pcre.yo
--- Doc/Zsh/mod_pcre.yo	1 May 2007 22:05:05 -0000	1.6
+++ Doc/Zsh/mod_pcre.yo	15 Jan 2009 00:45:31 -0000
@@ -26,13 +26,15 @@ item(tt(pcre_match) [ tt(-v) var(var) ] 
 Returns successfully if tt(string) matches the previously-compiled
 PCRE.
 
-If the expression captures substrings within parentheses,
+Upon successful match,
+if the expression captures substrings within parentheses,
 tt(pcre_match) will set the array var($match) to those
 substrings, unless the tt(-a) option is given, in which
 case it will set the array var(arr).  Similarly, the variable
 var(MATCH) will be set to the entire matched portion of the
 string, unless the tt(-v) option is given, in which case the variable
 var(var) will be set.
+No variables are altered if there is no successful match.
 )
 enditem()
 
Index: Doc/Zsh/mod_regex.yo
===================================================================
RCS file: /home/cvsroot/zsh/Doc/Zsh/mod_regex.yo,v
retrieving revision 1.1
diff -a -u -p -r1.1 mod_regex.yo
--- Doc/Zsh/mod_regex.yo	2 May 2007 11:13:15 -0000	1.1
+++ Doc/Zsh/mod_regex.yo	15 Jan 2009 00:44:33 -0000
@@ -8,9 +8,11 @@ startitem()
 findex(regex-match)
 item(var(expr) tt(-regex-match) var(regex))(
 Matches a string against a POSIX extended regular expression.
-The matched portion of the string will normally be placed in the tt(MATCH)
+On successful match,
+matched portion of the string will normally be placed in the tt(MATCH)
 variable.  If there are any capturing parentheses within the regex, then
 the tt(match) array variable will contain those.
+If the match is not successful, then the variables will not be altered.
 
 For example,
 



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