From d9ec53a9c767d86bb35608d72d831f7f5c8f4f79 Mon Sep 17 00:00:00 2001 From: sorah Date: Thu, 24 Dec 2015 06:35:49 +0000 Subject: * tool/vcs.rb (IO.popen): Refactor. Avoid assigning in condition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- tool/vcs.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tool/vcs.rb') diff --git a/tool/vcs.rb b/tool/vcs.rb index 92ae46f443..50c0607039 100644 --- a/tool/vcs.rb +++ b/tool/vcs.rb @@ -21,10 +21,12 @@ if RUBY_VERSION < "2.0" if defined?(fork) def self.popen(command, *rest, &block) - if Hash === (opts = rest[-1]) + opts = rest.last + if opts.kind_of?(Hash) dir = opts.delete(:chdir) rest.pop if opts.empty? end + if block @orig_popen.call("-", *rest) do |f| if f @@ -46,10 +48,12 @@ if RUBY_VERSION < "2.0" else require 'shellwords' def self.popen(command, *rest, &block) - if Hash === (opts = rest[-1]) + opts = rest.last + if opts.kind_of?(Hash) dir = opts.delete(:chdir) rest.pop if opts.empty? end + command = command.shelljoin if Array === command Dir.chdir(dir || ".") do @orig_popen.call(command, *rest, &block) -- cgit v1.2.3