diff options
| author | Jack Nagel | 2014-09-27 19:10:12 -0500 |
|---|---|---|
| committer | Jack Nagel | 2014-09-27 19:11:40 -0500 |
| commit | cb69f339b88bf58d7e40e87859e7efd13823eab7 (patch) | |
| tree | 07cd1268d3640aadc6352759b89c8b6befd818a4 /Library | |
| parent | 50b900daf30bda60bae97431bace55ca7df20834 (diff) | |
| download | brew-cb69f339b88bf58d7e40e87859e7efd13823eab7.tar.bz2 | |
Intercept calls to sub! in inreplace blocks
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/extend/string.rb | 14 |
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 |
