aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/global.rb
diff options
context:
space:
mode:
authorMax Howell2010-01-13 09:02:42 +0000
committerMax Howell2010-01-13 11:23:15 +0000
commit4f111dfd9a16c99b159a14ccd6904e237e9833d8 (patch)
tree20f4706b1af4ddae78b55aeb4c56a9f6632def99 /Library/Homebrew/global.rb
parent68074dc535169255e8c8848d27be45ebc53b4cfb (diff)
downloadhomebrew-4f111dfd9a16c99b159a14ccd6904e237e9833d8.tar.bz2
Print quotes around executed arguments with spaces
Eg: ['foo', 'bar la'] -> "foo 'bar la'"
Diffstat (limited to 'Library/Homebrew/global.rb')
-rw-r--r--Library/Homebrew/global.rb20
1 files changed, 16 insertions, 4 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