Skip to content

Reline behaves oddly with redirect (nontty output) #616

Closed

Description

@mtasaka

Forwarded from cucumber/aruba testsute issue cucumber/aruba#910 , then from https://bugs.ruby-lang.org/issues/20052

Looks line reline behaves oddly with redirect (non tty)

With ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux] and Readline (version 8.2):

$ echo 'foo' | ruby -e 'require "readline"; puts Readline.readline(">")' > bar.log ; cat bar.log 
> foo
foo

With ruby 3.3.0dev (2023-12-09 master 1cbe114d1c) [x86_64-linux] and Reline (version 4.1): (Reline installed from gem install)

$ echo 'foo' | ruby -e 'require "reline"; puts Reline.readline(">")' > bar.log ; cat bar.log 
>>> f>f>fo>fo>foo>foofoo

Activity

  1. tompng commented on Dec 11, 2023

    @tompng
    Member

    I think it is Reline's bug. Reline's output should make the terminal screen to show:

    >foo
    foo
    

    My understanding is that Reline does not aim to output exactly the same byte sequence as Readline. Reline's output can contain escape sequences or control characters like "\r>\r>f\r>foo\nfoo\n". Fixing this bug might not make the mentioned test pass.

    Note that Readline's output sometimes contains different escape sequence depending on version or environment.

    printf "ruby\x01\x04R\n" | ruby -rreadline -e 'puts Readline.readline(">")'
    # output(readline 8.2): ">ruby\r\e[C\e[1Puby\r\e[CRuby\b\b\b\nRuby\n"
    # output(readline 8.1): ">ruby\r>\e[1P\e[1@R\nRuby\n"
    # terminal screen: ">Ruby\nRuby\n"
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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions