diff options
author | aycabta <aycabta@gmail.com> | 2020-12-23 20:29:57 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2020-12-23 22:08:30 +0900 |
commit | 28e9344fa49387ef84c71a72d1ba7e32b61cf4c7 (patch) | |
tree | b930c0f9ca336f97407cd176bc37ae9e34ed3a83 /lib | |
parent | 129ecb43e54b3249734c69787f813d49ce995567 (diff) |
[ruby/irb] Change StdioInputMethod#eof? to non-blocking
This fixes --inf-ruby-mode.
https://github.com/ruby/irb/commit/0e4a818955
Diffstat (limited to 'lib')
-rw-r--r-- | lib/irb/input-method.rb | 10 |
1 files changed, 9 insertions, 1 deletions
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 |