aboutsummaryrefslogtreecommitdiffstats
path: root/tool
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-07 00:04:20 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-07 00:04:20 +0000
commit599de5be6e006743739834da0c5d484b47988b2f (patch)
tree045272a9b3c90a57b8efad671965e7421799238a /tool
parent7ae8b8140a334d7cfc548613aa1f896dca1e9755 (diff)
downloadruby-599de5be6e006743739834da0c5d484b47988b2f.tar.gz
vcs.rb: popen with env
* tool/vcs.rb (IO.popen): support passing environment variables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool')
-rw-r--r--tool/vcs.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/tool/vcs.rb b/tool/vcs.rb
index e663d86a98..97ff155914 100644
--- a/tool/vcs.rb
+++ b/tool/vcs.rb
@@ -24,6 +24,10 @@ if RUBY_VERSION < "2.0"
if defined?(fork)
def self.popen(command, *rest, &block)
+ if command.kind_of?(Hash)
+ env = command
+ command = rest.shift
+ end
opts = rest.last
if opts.kind_of?(Hash)
dir = opts.delete(:chdir)
@@ -36,6 +40,7 @@ if RUBY_VERSION < "2.0"
yield(f)
else
Dir.chdir(dir) if dir
+ ENV.replace(env) if env
exec(*command)
end
end
@@ -43,6 +48,7 @@ if RUBY_VERSION < "2.0"
f = @orig_popen.call("-", *rest)
unless f
Dir.chdir(dir) if dir
+ ENV.replace(env) if env
exec(*command)
end
f
@@ -51,6 +57,11 @@ if RUBY_VERSION < "2.0"
else
require 'shellwords'
def self.popen(command, *rest, &block)
+ if command.kind_of?(Hash)
+ env = command
+ oldenv = ENV.to_hash
+ command = rest.shift
+ end
opts = rest.last
if opts.kind_of?(Hash)
dir = opts.delete(:chdir)
@@ -59,7 +70,9 @@ if RUBY_VERSION < "2.0"
command = command.shelljoin if Array === command
Dir.chdir(dir || ".") do
+ ENV.replace(env) if env
@orig_popen.call(command, *rest, &block)
+ ENV.replace(oldenv) if oldenv
end
end
end