Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reline doesn't respect EOF from the terminal #501

Open
etiennebarrie opened this issue Jan 13, 2023 · 2 comments
Open

Reline doesn't respect EOF from the terminal #501

etiennebarrie opened this issue Jan 13, 2023 · 2 comments

Comments

@etiennebarrie
Copy link
Contributor

Description

When the terminal uses a different control character for EOF, it's not respected by reline.

By comparison with readline:

$ stty eof ^K # stty eof ^D to restore
$ ruby -rreadline -e Readline.readline
a^A^D^D^K

I type a, then ^A to go at the beginning of the line, then ^D to remove the a, the second ^D doesn't do anything, but ^K sends the end-of-file and ends the process.

$ stty eof ^K # stty eof ^D to restore
$ ruby -rreadline -e Readline.readline
a^A^K^K

I type a, then ^A to go at the beginning of the line, then ^K removes until the end of the line (kill-line), the second ^K sends the end-of-file and ends the process.


With reline:

$ stty eof ^K # stty eof ^D to restore
$ ruby -rreline -e Reline.readline
a^A^D^D

I type a, then ^A to go at the beginning of the line, then ^D to remove the a, the second ^D sends the end-of-file and ends the process.

$ stty eof ^K # stty eof ^D to restore
$ ruby -rreline -e Reline.readline
a^A^K^K^D

I type a, then ^A to go at the beginning of the line, then ^K removes until the end of the line (kill-line), the second ^K doesn't do anything, but ^D sends the end-of-file and ends the process.

Terminal Emulator

Terminal.app on macOS 13.1

@hasumikin
Copy link
Collaborator

It reproduces on Linux, too.
That's because Reline doesn't handle stty's modification, I guess.

@etiennebarrie
Could you tell me if there is some real-world troublesome case when the EOF attribute is modified?

@etiennebarrie
Copy link
Contributor Author

I don't have a real world use case, I personally don't modify stty like this.

I was just curious because I was trying to get the Del key in emacs mode to work like readline. Reline::ANSI::CAPNAME_KEY_BINDINGS["kdch1"] = :em_delete in my .irbrc mostly worked, but now the Del key was also behaving like Ctrl-D for end-of-file. To fix this I can hardcode Ctrl-D but I investigated a bit more to understand where Ctrl-D was coming from and if I could avoid hardcoding.

So for now I pushed #504, hard-coding Ctrl-D for EOF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants