From cb69f339b88bf58d7e40e87859e7efd13823eab7 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sat, 27 Sep 2014 19:10:12 -0500 Subject: Intercept calls to sub! in inreplace blocks --- Library/Homebrew/extend/string.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'Library') 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 -- cgit v1.2.3