Skip to content

Input with eof and no newline bugfix - #671

Merged
ima1zumi merged 1 commit into
ruby:masterfrom
tompng:fix_read_eof_terminated_input
Apr 29, 2024
Merged

ima1zumi merged 1 commit into
ruby:masterfrom
tompng:fix_read_eof_terminated_input

Conversation

@tompng

@tompng tompng commented Apr 3, 2024

Copy link
Copy Markdown
Member

Fix the bug below

# with readline-ext
$ printf "hello" | ruby -rreadline -e "p Readline.readline('>')"
>hello
"hello"

# with Reline master
$ printf "hello" | ruby -Ilib -rreline -e "p Reline.readline('>')"
>
""

The string "hello" is stored in @continuous_insertion_buffer, need to force input before finishing read.

In some environment (in my M2 Mac), pread raises IOError, so rescue Errno::ESPIPE, IOError change in ansi.rb is needed to test it.

start_terminal(40, 50, ['bash', '-c', cmd])
sleep 1
close
close rescue nil

@tompng tompng Apr 3, 2024 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was always failing in my local environment.
If sleep on the previous line is too long, close will raise EOFError: end of file reached. If sleep time is too short, assert_screen will fail.
(In my environment, even sleep 0 is too long because start_terminal and close has sleep 0.1 internally. There is no best value. Need to fix yamatanooroti.)

@ima1zumi ima1zumi added the bug Something isn't working label Apr 5, 2024

@ima1zumi ima1zumi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@ima1zumi
ima1zumi merged commit 0d66c33 into ruby:master Apr 29, 2024
@tompng
tompng deleted the fix_read_eof_terminated_input branch April 29, 2024 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants