aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/util.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2019-06-01 12:45:11 +0300
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-06-01 13:50:41 +0300
commit56660de3c6df7a4ff8667ef4047d30d0de169935 (patch)
treedd1e526075687b4b24e089cee50eabc21a6143cc /lib/rubygems/util.rb
parent560cd5b1f04f30542a294b3d77527d3b12f7cc15 (diff)
downloadruby-56660de3c6df7a4ff8667ef4047d30d0de169935.tar.gz
Merge rubygems master from upstream.
I picked the commit from 3c469e0da538428a0ddd94f99aa73c32da22e8ba
Diffstat (limited to 'lib/rubygems/util.rb')
-rw-r--r--lib/rubygems/util.rb54
1 files changed, 14 insertions, 40 deletions
diff --git a/lib/rubygems/util.rb b/lib/rubygems/util.rb
index 401e5609f7..b5f1408401 100644
--- a/lib/rubygems/util.rb
+++ b/lib/rubygems/util.rb
@@ -44,29 +44,10 @@ module Gem::Util
end
##
- # This calls IO.popen where it accepts an array for a +command+ (Ruby 1.9+)
- # and implements an IO.popen-like behavior where it does not accept an array
- # for a command.
+ # This calls IO.popen and reads the result
def self.popen(*command)
IO.popen command, &:read
- rescue TypeError # ruby 1.8 only supports string command
- r, w = IO.pipe
-
- pid = fork do
- STDIN.close
- STDOUT.reopen w
-
- exec(*command)
- end
-
- w.close
-
- begin
- return r.read
- ensure
- Process.wait pid
- end
end
##
@@ -80,26 +61,7 @@ module Gem::Util
else
cmds = command.dup
end
- return system(*(cmds << opt))
- rescue TypeError
- @silent_mutex ||= Mutex.new
-
- @silent_mutex.synchronize do
- begin
- stdout = STDOUT.dup
- stderr = STDERR.dup
-
- STDOUT.reopen IO::NULL, 'w'
- STDERR.reopen IO::NULL, 'w'
-
- return system(*command)
- ensure
- STDOUT.reopen stdout
- STDERR.reopen stderr
- stdout.close
- stderr.close
- end
- end
+ system(*(cmds << opt))
end
##
@@ -130,4 +92,16 @@ module Gem::Util
end
end
+ ##
+ # Corrects +path+ (usually returned by `URI.parse().path` on Windows), that
+ # comes with a leading slash.
+
+ def self.correct_for_windows_path(path)
+ if path[0].chr == '/' && path[1].chr =~ /[a-z]/i && path[2].chr == ':'
+ path[1..-1]
+ else
+ path
+ end
+ end
+
end