Skip to content

Reline doesn't respect EOF from the terminal #501

Open

Description

@etiennebarrie

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

Activity

  1. hasumikin commented on Jan 18, 2023

    @hasumikin
    Contributor

    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?

  2. etiennebarrie commented on Jan 18, 2023

    @etiennebarrie
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions