Skip to content

Reline emits extra escape sequences when stdin/stdout/stderr are not TTY #886

@eregon

Description

@eregon

Reline 0.6.0 from Ruby 3.4.7 (same with reline 0.6.3 the last release):

$ echo 'my input' > in
$ ruby -rreadline -e 'p Readline; p [STDIN,STDOUT,STDERR].map(&:tty?); p Readline.readline("> ", true)' < in |& ruby -e 'p STDIN.read'            
"Reline\n[false, false, false]\n> \e[?25l\e[1G\e[K\e[1G\e[0m> \e[0m\e[?25h\e[3G\e[?25l\e[1G\e[K\e[?25h\e[1G> my input\r\n\e[1G\"my input\"\n"

Even though STDIN, STDOUT, STDERR are all not TTY, terminal escape sequences are still included.
This causes issues for e.g. this program using Readline.readline because it's supposed to work well both if TTY or not. If not TTY, it expects no escape sequences.
That works with Readline from readline-ext but not Reline (as-is at least).

TERM=dumb doesn't help, it outputs many extra things (#660):

$ TERM=dumb ruby -rreadline -e 'p Readline; p [STDIN,STDOUT,STDERR].map(&:tty?); p Readline.readline("> ", true)' < in |& ruby -e 'p STDIN.read' 
"Reline\n[false, false, false]\n> > mmymy my imy inmy inpmy inpumy input> my input\r\n\"my input\"\n"

readline-ext for comparison works fine:

$ gem i readline-ext  
$ ruby -rreadline -e 'p Readline; p [STDIN,STDOUT,STDERR].map(&:tty?); p Readline.readline("> ", true)' < in |& ruby -e 'p STDIN.read'
"Readline\n[false, false, false]\n> my input\n\"my input\"\n"

Is there a way to achieve the same with Reline?

Related: #644

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