zsh-workers
 help / color / mirror / code / Atom feed
From: Phil Pennock <zsh-workers+phil.pennock@spodhuis.org>
To: zsh-workers@sunsite.dk
Subject: [PATCH] documentation update =~ regex MATCH
Date: Wed, 14 Jan 2009 16:53:04 -0800	[thread overview]
Message-ID: <20090115005304.GA9290@redoubt.spodhuis.org> (raw)

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,
 


                 reply	other threads:[~2009-01-15  0:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090115005304.GA9290@redoubt.spodhuis.org \
    --to=zsh-workers+phil.pennock@spodhuis.org \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).