[MacRuby] #1429: STDIN.eof? consumes first input character
#1429: STDIN.eof? consumes first input character --------------------------------+------------------------------------------- Reporter: lastobelus@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: --------------------------------+------------------------------------------- {{{ irb(main):045:0> def test irb(main):046:1> STDIN.eof? irb(main):047:1> STDIN.gets irb(main):048:0> end => nil irb(main):049:0> test bob => "ob\n" }}} - I checked File and StringIO, they do not show this bug. - I was unable to come up with a workaround that would work with client code calling STDIN.eof? then STDIN.gets. Any suggestions would be appreciated. I tried STDIN.reopen and STDIN.rewind -- Ticket URL: <http://www.macruby.org/trac/ticket/1429> MacRuby <http://macruby.org/>
#1429: STDIN.eof? consumes first input character --------------------------------+------------------------------------------- Reporter: lastobelus@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: --------------------------------+------------------------------------------- Comment(by lastobelus@…): I ended up doing this: {{{ STDIN.define_singleton_method(:eof?) { false } }}} which was fine for my purpose, but would be a problem for client code that checks eof? and does not also check if gets/readline returns nil -- Ticket URL: <http://www.macruby.org/trac/ticket/1429#comment:1> MacRuby <http://macruby.org/>
#1429: STDIN.eof? consumes first input character --------------------------------+------------------------------------------- Reporter: lastobelus@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: --------------------------------+------------------------------------------- Comment(by chris@…): I was not able to reproduce this as of git revision: eabb31c50770c22979477c00536a09bede2ed303 {{{ def test STDIN.eof? STDIN.gets end x = test if x == "foo\n" puts "PASS" else puts "FAIL, got '#{x}'" end ➜ MacRuby git:(master) ✗ echo "foo" | ./macruby test_io.rb PASS }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1429#comment:2> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby