[前][次][番号順一覧][スレッド一覧]

ruby-changes:72058

From: Nobuyoshi <ko1@a...>
Date: Sat, 4 Jun 2022 20:32:51 +0900 (JST)
Subject: [ruby-changes:72058] 5460675bbc (master): [ruby/rdoc] Use command array form of `IO.popen` always

https://git.ruby-lang.org/ruby.git/commit/?id=5460675bbc

From 5460675bbc5b56b422fce686493f87927620b8df Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sat, 4 Jun 2022 20:32:23 +0900
Subject: [ruby/rdoc] Use command array form of `IO.popen` always

So that an exception raises by non-existent command, not via shell.

https://github.com/ruby/rdoc/commit/fd94dce69d
---
 lib/rdoc/ri/driver.rb | 50 ++++----------------------------------------------
 1 file changed, 4 insertions(+), 46 deletions(-)

diff --git a/lib/rdoc/ri/driver.rb b/lib/rdoc/ri/driver.rb
index 610d78ae68..a9d7205554 100644
--- a/lib/rdoc/ri/driver.rb
+++ b/lib/rdoc/ri/driver.rb
@@ -426,9 +426,6 @@ or the PAGER environment variable. https://github.com/ruby/ruby/blob/trunk/lib/rdoc/ri/driver.rb#L426
     @use_stdout  = options[:use_stdout]
     @show_all    = options[:show_all]
     @width       = options[:width]
-
-    # pager process for jruby
-    @jruby_pager_process = nil
   end
 
   ##
@@ -1044,36 +1041,6 @@ or the PAGER environment variable. https://github.com/ruby/ruby/blob/trunk/lib/rdoc/ri/driver.rb#L1041
     self
   end
 
-  ##
-  # Finds the given +pager+ for jruby.  Returns an IO if +pager+ was found.
-  #
-  # Returns false if +pager+ does not exist.
-  #
-  # Returns nil if the jruby JVM doesn't support ProcessBuilder redirection
-  # (1.6 and older).
-
-  def find_pager_jruby pager
-    require 'java'
-    require 'shellwords'
-
-    return nil unless java.lang.ProcessBuilder.constants.include? :Redirect
-
-    pager = Shellwords.split pager
-
-    pb = java.lang.ProcessBuilder.new(*pager)
-    pb = pb.redirect_output java.lang.ProcessBuilder::Redirect::INHERIT
-
-    @jruby_pager_process = pb.start
-
-    input = @jruby_pager_process.output_stream
-
-    io = input.to_io
-    io.sync = true
-    io
-  rescue java.io.IOException
-    false
-  end
-
   ##
   # Finds a store that matches +name+ which can be the name of a gem, "ruby",
   # "home" or "site".
@@ -1503,23 +1470,14 @@ or the PAGER environment variable. https://github.com/ruby/ruby/blob/trunk/lib/rdoc/ri/driver.rb#L1470
   def setup_pager
     return if @use_stdout
 
-    jruby = RUBY_ENGINE == 'jruby'
-
     pagers = [ENV['RI_PAGER'], ENV['PAGER'], 'pager', 'less', 'more']
 
+    require 'shellwords'
     pagers.compact.uniq.each do |pager|
-      next unless pager
-
-      if jruby then
-        case io = find_pager_jruby(pager)
-        when nil   then break
-        when false then next
-        else            io
-        end
-      else
-        io = IO.popen(pager, 'w') rescue next
-      end
+      pager = Shellwords.split(pager)
+      next if pager.empty?
 
+      io = IO.popen(pager, 'w') rescue next
       next if $? and $?.pid == io.pid and $?.exited? # pager didn't work
 
       @paging = true
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]