aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-25 07:55:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-25 07:55:55 +0000
commitad989e5521172a9e51f7cbc1b568faf500bdcf24 (patch)
tree8e26dc76187289e96371047f76d0fec46696f879 /lib/rubygems
parent892a97ebebb04d79f1111300a3b62ebde5edbb97 (diff)
downloadruby-ad989e5521172a9e51f7cbc1b568faf500bdcf24.tar.gz
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
Diffstat (limited to 'lib/rubygems')
-rw-r--r--lib/rubygems/util.rb13
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