summaryrefslogtreecommitdiff
path: root/lib/rubygems/util.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/util.rb')
-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