diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-07-25 07:55:55 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-07-25 07:55:55 +0000 |
commit | ad989e5521172a9e51f7cbc1b568faf500bdcf24 (patch) | |
tree | 8e26dc76187289e96371047f76d0fec46696f879 | |
parent | 892a97ebebb04d79f1111300a3b62ebde5edbb97 (diff) |
rubygems/util.rb: redirect options
* lib/rubygems/util.rb (Gem.silent_system): use keyword options to
redirect outputs instead of reopening global IOs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | lib/rubygems/util.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/rubygems/util.rb b/lib/rubygems/util.rb index 9642839cfc..daa9775b08 100644 --- a/lib/rubygems/util.rb +++ b/lib/rubygems/util.rb @@ -66,15 +66,26 @@ module Gem::Util end end + NULL_DEVICE = defined?(IO::NULL) ? IO::NULL : Gem.win_platform? ? 'NUL' : '/dev/null' + ## # Invokes system, but silences all output. def self.silent_system *command + opt = {:out => NULL_DEVICE, :err => [:child, :out]} + if Hash === command.last + opt.update(command.last) + cmds = command[0...-1] + else + cmds = command.dup + end + return system(*(cmds << opt)) + rescue TypeError => e require 'thread' @silent_mutex ||= Mutex.new - null_device = Gem.win_platform? ? 'NUL' : '/dev/null' + null_device = NULL_DEVICE @silent_mutex.synchronize do begin |