diff options
| author | Max Howell | 2010-01-13 09:02:42 +0000 |
|---|---|---|
| committer | Max Howell | 2010-01-13 11:23:15 +0000 |
| commit | 0a27f041d03ff1196156eecc2ccfc9db05d1840c (patch) | |
| tree | ee825c94c7aa5e7f55b6a4c5ae4c4d12eba82ae2 | |
| parent | 2037b2373ab094830ade980efd816b50035f1390 (diff) | |
| download | brew-0a27f041d03ff1196156eecc2ccfc9db05d1840c.tar.bz2 | |
Print quotes around executed arguments with spaces
Eg: ['foo', 'bar la'] -> "foo 'bar la'"
| -rw-r--r-- | Library/Homebrew/global.rb | 20 | ||||
| -rwxr-xr-x | bin/brew | 2 |
2 files changed, 17 insertions, 5 deletions
diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index ce79da2ec..92513294f 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -61,11 +61,23 @@ HOMEBREW_USER_AGENT = "Homebrew #{HOMEBREW_VERSION} (Ruby #{RUBY_VERSION}-#{RUBY class ExecutionError <RuntimeError - attr :status + attr :exit_status - def initialize cmd, args=[], status=nil - super "Failure while executing: #{cmd} #{args*' '}" - @status = status + def initialize cmd, args = [], es = nil + super "Failure while executing: #{cmd} #{pretty(args)*' '}" + @exit_status = es.exitstatus rescue 1 + end + + private + + def pretty args + args.collect do |arg| + if arg.include? ' ' + "'#{ arg.gsub "'", "\\'" }'" + else + arg + end + end end end @@ -331,7 +331,7 @@ rescue BuildError => e puts "http://github.com/mxcl/homebrew/blob/master/Library/Formula/#{formula_name}.rb#L#{$2}" ohai "Environment" dump_config - puts "Exit status: #{e.status.exitstatus}" + puts "Exit status: #{e.exit_status}" onoe e puts PLEASE_REPORT_BUG # this feature can be slow (depends on network conditions and if github is up) |
