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

ruby-changes:59363

From: Nobuyoshi <ko1@a...>
Date: Sun, 22 Dec 2019 05:03:03 +0900 (JST)
Subject: [ruby-changes:59363] 7fd6077d98 (master): [ruby/reline] Consider Reline::ANSI.input at prep

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

From 7fd6077d9896cc10244fb9416ef87ae461c079db Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sat, 14 Dec 2019 11:01:49 +0900
Subject: [ruby/reline] Consider Reline::ANSI.input at prep

https://github.com/ruby/reline/commit/b111cde3c3

diff --git a/lib/reline/ansi.rb b/lib/reline/ansi.rb
index e29ee75..21c0540 100644
--- a/lib/reline/ansi.rb
+++ b/lib/reline/ansi.rb
@@ -120,20 +120,29 @@ class Reline::ANSI https://github.com/ruby/ruby/blob/trunk/lib/reline/ansi.rb#L120
   def self.prep
     retrieve_keybuffer
     int_handle = Signal.trap('INT', 'IGNORE')
-    otio = `stty -g`.chomp
-    setting = ' -echo -icrnl cbreak -ixoff -iexten'
-    stty = `stty -a`
-    if /-parenb\b/ =~ stty
-      setting << ' pass8'
+    begin
+      otio = IO.popen(%w[stty -g], in: @@input, &:read).chomp
+    rescue ArgumentError
+    else
+      setting = %w'-echo -icrnl cbreak -ixoff -iexten'
+      stty = IO.popen(%w[stty -a], in: @@input, &:read)
+      if /-parenb\b/ =~ stty
+        setting << 'pass8'
+      end
+      system("stty", *setting, in: @@input)
     end
-    `stty #{setting}`
     Signal.trap('INT', int_handle)
     otio
   end
 
   def self.deprep(otio)
     int_handle = Signal.trap('INT', 'IGNORE')
-    system("stty #{otio}", err: File::NULL)
+    if otio
+      begin
+        system("stty #{otio}", in: @@input, err: File::NULL)
+      rescue ArgumentError
+      end
+    end
     Signal.trap('INT', int_handle)
     Signal.trap('WINCH', @@old_winch_handler) if @@old_winch_handler
   end
-- 
cgit v0.10.2


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

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