ruby-changes:41199
From: sorah <ko1@a...>
Date: Thu, 24 Dec 2015 15:35:55 +0900 (JST)
Subject: [ruby-changes:41199] sorah:r53271 (trunk): * tool/vcs.rb (IO.popen): Refactor. Avoid assigning in condition.
sorah 2015-12-24 15:35:49 +0900 (Thu, 24 Dec 2015) New Revision: 53271 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53271 Log: * tool/vcs.rb (IO.popen): Refactor. Avoid assigning in condition. Modified files: trunk/ChangeLog trunk/tool/vcs.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 53270) +++ ChangeLog (revision 53271) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Dec 24 15:02:42 2015 sorah (Shota Fukumori) <her@s...> + + * tool/vcs.rb (IO.popen): Refactor. Avoid assigning in condition. + Thu Dec 24 15:01:38 2015 sorah (Shota Fukumori) <her@s...> * tool/file2lastrev.rb: Fix ArgumentError to work on Ruby 1.8.7. Index: tool/vcs.rb =================================================================== --- tool/vcs.rb (revision 53270) +++ tool/vcs.rb (revision 53271) @@ -21,10 +21,12 @@ if RUBY_VERSION < "2.0" https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L21 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" https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L48 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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/