From ac7a59373087e9d49097ab7f0ddb691e64159959 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Thu, 12 Jan 2017 07:22:34 -0800 Subject: [PATCH] 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(-) diff --git a/Library/Homebrew/utils/inreplace.rb b/Library/Homebrew/utils/inreplace.rb index c7557ab41d..b4c219f064 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