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

ruby-changes:62641

From: aycabta <ko1@a...>
Date: Wed, 19 Aug 2020 11:19:12 +0900 (JST)
Subject: [ruby-changes:62641] e939a5c29f (master): Use "in" and "out" options of "system" instead of "replace_stdio"

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

From e939a5c29f3ca57e852d69cbecac2936035e96c7 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Wed, 19 Aug 2020 11:09:18 +0900
Subject: Use "in" and "out" options of "system" instead of "replace_stdio"


diff --git a/test/irb/test_history.rb b/test/irb/test_history.rb
index f9193e5..b811bbe 100644
--- a/test/irb/test_history.rb
+++ b/test/irb/test_history.rb
@@ -119,9 +119,7 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_history.rb#L119
           yield(stdin, stdout)
           stdin.close
           stdout.flush
-          replace_stdio(stdin.path, stdout.path) do
-            system('ruby', '-Ilib', '-Itest', '-W0', '-rirb', '-e', 'IRB.start(__FILE__)')
-          end
+          system('ruby', '-Ilib', '-Itest', '-W0', '-rirb', '-e', 'IRB.start(__FILE__)', in: stdin.path, out: stdout.path)
           result = stdout.read
           stdout.close
         end
@@ -147,30 +145,5 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_history.rb#L145
         end
       end
     end
-
-    def replace_stdio(stdin_path, stdout_path)
-      open(stdin_path, "r") do |stdin|
-        open(stdout_path, "w") do |stdout|
-          orig_stdin = STDIN.dup
-          orig_stdout = STDOUT.dup
-          orig_stderr = STDERR.dup
-          STDIN.reopen(stdin)
-          STDOUT.reopen(stdout)
-          STDERR.reopen(stdout)
-          begin
-            #Readline.input = STDIN
-            #Readline.output = STDOUT
-            yield
-          ensure
-            STDERR.reopen(orig_stderr)
-            STDIN.reopen(orig_stdin)
-            STDOUT.reopen(orig_stdout)
-            orig_stdin.close
-            orig_stdout.close
-            orig_stderr.close
-          end
-        end
-      end
-    end
   end
 end
-- 
cgit v0.10.2


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

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