about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-01-19 13:13:56 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-01-19 13:13:56 +0000
commit1c71dfd735f34b2b3c7cf8abc3144e763fc96b60 (patch)
tree501c56d48a1bff26c8560e82a0a7ef2cd22c857e
parent7ec0c64b4d3a6131acf5c08c51b30b89309e0ac6 (diff)
downloadzsh-1c71dfd735f34b2b3c7cf8abc3144e763fc96b60.tar.gz
zsh-1c71dfd735f34b2b3c7cf8abc3144e763fc96b60.tar.xz
zsh-1c71dfd735f34b2b3c7cf8abc3144e763fc96b60.zip
unposted: return status 1 if no replacement
-rw-r--r--ChangeLog5
-rw-r--r--Functions/Misc/regexp-replace8
2 files changed, 12 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index a86d11bea..6bf85e2f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2010-01-19  Peter Stephenson  <pws@csr.com>
 
+	* unposted: Doc/Zsh/contrib.yo, Functions/Misc/regexp-replace:
+	return status 1 if no replacement.
+
 	* unposted: Doc/Zsh/cond.yo: avoid Yodl error.
 
 	* Frank: 27606: Completion/Unix/Command/_tmux: tmux -d.
@@ -12606,5 +12609,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.4866 $
+* $Revision: 1.4867 $
 *****************************************************
diff --git a/Functions/Misc/regexp-replace b/Functions/Misc/regexp-replace
index 5aaedafba..dec105524 100644
--- a/Functions/Misc/regexp-replace
+++ b/Functions/Misc/regexp-replace
@@ -19,13 +19,19 @@ emulate -L zsh
 4=${(P)1}
 # $5 is the final string
 5=
+# 6 indicates if we made a change
+6=
 local MATCH MBEGIN MEND
 local -a match mbegin mend
 
 while [[ -n $4 ]]; do
   if [[ $4 =~ $2 ]]; then
+    # append initial part and subsituted match
     5+=${4[1,MBEGIN-1]}${(e)3}
+    # truncate remaining string
     4=${4[MEND+1,-1]}
+    # indicate we did something
+    6=1
   else
     break
   fi
@@ -33,3 +39,5 @@ done
 5+=$4
 
 eval ${1}=${(q)5}
+# status 0 if we did something, else 1.
+[[ -n $6 ]]