aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--tool/vcs.rb8
2 files changed, 10 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 18b2d19bc1..4f966e73ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Dec 24 15:02:42 2015 sorah (Shota Fukumori) <her@sorah.jp>
+
+ * tool/vcs.rb (IO.popen): Refactor. Avoid assigning in condition.
+
Thu Dec 24 15:01:38 2015 sorah (Shota Fukumori) <her@sorah.jp>
* tool/file2lastrev.rb: Fix ArgumentError to work on Ruby 1.8.7.
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)