[前][次][番号順一覧][スレッド一覧]

ruby-changes:34864

From: nobu <ko1@a...>
Date: Fri, 25 Jul 2014 16:56:11 +0900 (JST)
Subject: [ruby-changes:34864] nobu:r46947 (trunk): rubygems/util.rb: redirect options

nobu	2014-07-25 16:55:55 +0900 (Fri, 25 Jul 2014)

  New Revision: 46947

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46947

  Log:
    rubygems/util.rb: redirect options
    
    * lib/rubygems/util.rb (Gem.silent_system): use keyword options to
      redirect outputs instead of reopening global IOs.

  Modified files:
    trunk/lib/rubygems/util.rb
Index: lib/rubygems/util.rb
===================================================================
--- lib/rubygems/util.rb	(revision 46946)
+++ lib/rubygems/util.rb	(revision 46947)
@@ -66,15 +66,26 @@ module Gem::Util https://github.com/ruby/ruby/blob/trunk/lib/rubygems/util.rb#L66
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]