Project

General

Profile

Actions

Bug #14691

closed

ANSI Erase in Line not working properly in Windows

Added by rsranger65 (Alex Gittemeier) about 6 years ago. Updated about 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x64-mingw32]
[ruby-core:86560]

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:

Hello worl
Whats up?
Hello worl
Whats up?
           !
Whats up?

But instead I get:

          d!
What is up?
          d!
What is up?
          d!
What is up?

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

Actions

Also available in: Atom PDF

Like0
Like0Like0