From ad989e5521172a9e51f7cbc1b568faf500bdcf24 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 25 Jul 2014 07:55:55 +0000 Subject: 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 --- lib/rubygems/util.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 -- cgit v1.2.1