From 28e9344fa49387ef84c71a72d1ba7e32b61cf4c7 Mon Sep 17 00:00:00 2001 From: aycabta Date: Wed, 23 Dec 2020 20:29:57 +0900 Subject: [PATCH] [ruby/irb] Change StdioInputMethod#eof? to non-blocking This fixes --inf-ruby-mode. https://github.com/ruby/irb/commit/0e4a818955 --- lib/irb/input-method.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb index 6e87488753..61540a106f 100644 --- a/lib/irb/input-method.rb +++ b/lib/irb/input-method.rb @@ -83,7 +83,15 @@ module IRB # # See IO#eof? for more information. def eof? - @stdin.eof? + rs, = IO.select([@stdin], [], [], 0.00001) + if rs and rs[0] + c = @stdin.getc + result = c.nil? ? true : false + @stdin.ungetc(c) unless c.nil? + result + else # buffer is empty + false + end end # Whether this input method is still readable when there is no more data to