mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
892a97ebeb
commit
ad989e5521
1 changed files with 12 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue