aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2014-09-27 19:10:12 -0500
committerJack Nagel2014-09-27 19:11:40 -0500
commit3081621a457c70548c9637ff5ab94c3ccd37808d (patch)
treebb5154cf2386f01a666d4eae150658bb70e9ee8c /Library
parent9a4e3f58d9e6e45027394fdb8ae154864ece46d7 (diff)
downloadhomebrew-3081621a457c70548c9637ff5ab94c3ccd37808d.tar.bz2
Intercept calls to sub! in inreplace blocks
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/extend/string.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/Library/Homebrew/extend/string.rb b/Library/Homebrew/extend/string.rb
index d18539b5c..d85e029f3 100644
--- a/Library/Homebrew/extend/string.rb
+++ b/Library/Homebrew/extend/string.rb
@@ -56,13 +56,21 @@ end
# used by the inreplace function (in utils.rb)
module StringInreplaceExtension
+ def sub! before, after
+ result = super
+ unless result
+ opoo "inreplace: replacement of '#{before}' with '#{after}' failed"
+ end
+ result
+ end
+
# Warn if nothing was replaced
def gsub! before, after, audit_result=true
- sub = super(before, after)
- if audit_result and sub.nil?
+ result = super(before, after)
+ if audit_result && result.nil?
opoo "inreplace: replacement of '#{before}' with '#{after}' failed"
end
- return sub
+ result
end
# Looks for Makefile style variable defintions and replaces the