Reline emits extra escape sequences when stdin/stdout/stderr are not TTY
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 68/100
Research direction
Start with the reported Readline.readline reproduction using redirected stdin, stdout, and stderr, then compare its output with readline-ext. Review the linked TruffleRuby can-we-fold-yet test and expected.txt to define the non-TTY result. Done means Reline emits no terminal escape sequences when all three streams are not TTYs, while preserving interactive behavior.
Written by the indexing model from the issue text.
Description
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?
- Dominant language
- Ruby
- Stars
- 311
- Forks
- 99
- Avg merge
- 6d 4h
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ruby/reline
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bensheldon/good_job#1816 · 5 comments ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·