Pass command and arg list into ErrorDuringExecution constructor
This commit is contained in:
parent
7a4e2fe24d
commit
56dd575f96
@ -222,7 +222,7 @@ class Updater
|
||||
out = super
|
||||
if $? && !$?.success?
|
||||
$stderr.puts out
|
||||
raise ErrorDuringExecution, "Failure while executing: #{cmd}"
|
||||
raise ErrorDuringExecution.new(cmd)
|
||||
end
|
||||
ohai(cmd, out) if ARGV.verbose?
|
||||
out
|
||||
|
||||
@ -214,7 +214,12 @@ end
|
||||
class CurlDownloadStrategyError < RuntimeError; end
|
||||
|
||||
# raised by safe_system in utils.rb
|
||||
class ErrorDuringExecution < RuntimeError; end
|
||||
class ErrorDuringExecution < RuntimeError
|
||||
def initialize(cmd, args=[])
|
||||
args = args.map { |a| a.to_s.gsub " ", "\\ " }.join(" ")
|
||||
super "Failure while executing: #{cmd} #{args}"
|
||||
end
|
||||
end
|
||||
|
||||
# raised by Pathname#verify_checksum when "expected" is nil or empty
|
||||
class ChecksumMissingError < ArgumentError; end
|
||||
|
||||
@ -66,8 +66,9 @@ class EmbeddedPatch
|
||||
|
||||
def apply
|
||||
data = contents.gsub("HOMEBREW_PREFIX", HOMEBREW_PREFIX)
|
||||
IO.popen("/usr/bin/patch -g 0 -f -#{strip}", "w") { |p| p.write(data) }
|
||||
raise ErrorDuringExecution, "Applying DATA patch failed" unless $?.success?
|
||||
cmd, args = "/usr/bin/patch", %W[-g 0 -f -#{strip}]
|
||||
IO.popen("#{cmd} #{args.join(" ")}", "w") { |p| p.write(data) }
|
||||
raise ErrorDuringExecution.new(cmd, args) unless $?.success?
|
||||
end
|
||||
|
||||
def inspect
|
||||
|
||||
@ -127,10 +127,7 @@ end
|
||||
|
||||
# Kernel.system but with exceptions
|
||||
def safe_system cmd, *args
|
||||
unless Homebrew.system cmd, *args
|
||||
args = args.map{ |arg| arg.to_s.gsub " ", "\\ " } * " "
|
||||
raise ErrorDuringExecution, "Failure while executing: #{cmd} #{args}"
|
||||
end
|
||||
Homebrew.system(cmd, *args) or raise ErrorDuringExecution.new(cmd, args)
|
||||
end
|
||||
|
||||
# prints no output
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user