Bug #14691
closedANSI Erase in Line not working properly in Windows
Description
When I run the following commands in either the Windows 10 Command Prompt
ruby -e 'puts "Hello world!\e[D\e[D\e[K\nWhat is up?"'
ruby -e 'puts "Hello world!\e[D\e[D\e[0K\nWhat is up?"'
ruby -e 'puts "Hello world!\e[D\e[D\e[1K\nWhat is up?"'
I expect to get the same output as from:
printf "Hello world!\\e[D\\e[D\\e[K\nWhats up?\n"
printf "Hello world!\\e[D\\e[D\\e[0K\nWhats up?\n"
printf "Hello world!\\e[D\\e[D\\e[1K\nWhats up?\n"
Which is:
But instead I get:
The same behavior occurs in PowerShell as well, with appropriate changes to escaping (escaping the double quotes in the ruby code).
It appears that for the CSI [n] K sequences, n=0 (the default) and n=1 are doing the same operation and that n=1 has an off by one error
Windows version: Version 10.0.16299 Build 16299
Updated by shevegen (Robert A. Heiler) over 7 years ago
has an off by one error
It's always these two major problems in the fields of computer and programming:
- Giving something a good name (see matz's recent comment on a matz bot AI rejecting not ideal names for an API)
- Simplicity versus Complexity in general
- Off by one errors
:D
Updated by nobu (Nobuyoshi Nakada) over 7 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r63187.
win32.c: fix CSI sequences to delete
-
win32/win32.c (constat_apply): CSI 'J' and 'K' are defaulted to
1, not 0. [ruby-core:86560] [Bug #14691] -
win32/win32.c (constat_apply): "delete before cursor" sequences
include the cursor position.