diff options
author | sorah <sorah@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-24 06:35:49 +0000 |
---|---|---|
committer | sorah <sorah@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-24 06:35:49 +0000 |
commit | d9ec53a9c767d86bb35608d72d831f7f5c8f4f79 (patch) | |
tree | 511a2ff214a5c1676e551f93447e1e46cf85d7e7 /tool | |
parent | b85a79107a7e09d389bdc56f2fd175d2916c07fb (diff) |
* 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
Diffstat (limited to 'tool')
-rw-r--r-- | tool/vcs.rb | 8 |
1 files changed, 6 insertions, 2 deletions
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) |