aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend
diff options
context:
space:
mode:
authorJack Nagel2014-09-27 19:10:12 -0500
committerJack Nagel2014-09-27 19:11:40 -0500
commitcb69f339b88bf58d7e40e87859e7efd13823eab7 (patch)
tree07cd1268d3640aadc6352759b89c8b6befd818a4 /Library/Homebrew/extend
parent50b900daf30bda60bae97431bace55ca7df20834 (diff)
downloadbrew-cb69f339b88bf58d7e40e87859e7efd13823eab7.tar.bz2
Intercept calls to sub! in inreplace blocks
Diffstat (limited to 'Library/Homebrew/extend')
-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