From ac7a59373087e9d49097ab7f0ddb691e64159959 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Thu, 12 Jan 2017 07:22:34 -0800 Subject: InreplaceError: fix undefined method crash When the first parameter to inreplace was an array, and the replacement failed, InreplaceError would end up crashing with an undefined method exception because the order of operations resulted in super not being passed the value of the entire inject block. --- Library/Homebrew/utils/inreplace.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Library/Homebrew/utils') diff --git a/Library/Homebrew/utils/inreplace.rb b/Library/Homebrew/utils/inreplace.rb index c7557ab41..b4c219f06 100644 --- a/Library/Homebrew/utils/inreplace.rb +++ b/Library/Homebrew/utils/inreplace.rb @@ -1,9 +1,10 @@ module Utils class InreplaceError < RuntimeError def initialize(errors) - super errors.inject("inreplace failed\n") do |s, (path, errs)| + formatted_errors = errors.inject("inreplace failed\n") do |s, (path, errs)| s << "#{path}:\n" << errs.map { |e| " #{e}\n" }.join end + super formatted_errors end end -- cgit v1.2.3