Bug 48109 - konsole gets confused by ANSI sequences
Summary: konsole gets confused by ANSI sequences
Status: RESOLVED INTENTIONAL
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
: 138413 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-09-21 14:18 UTC by Thomas Koeller
Modified: 2007-03-09 18:20 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koeller 2002-09-21 14:18:14 UTC
Version:            (using KDE KDE 3.0.3)
Installed from:    Compiled From Sources
Compiler:          gcc-3.2 
OS:          Linux

The use of ANSI sequences in konsole seems to confuse konsole's idea of where the current write position is. When I run a bash shell inside konsole and set the prompt string to contain ANSI escape sequences, then when typing long lines the write position wraps back to the beginning of the current line before the right margin has been reached. The same behaviour can be observed with xterm, so the problem obviously has been inherited from there.
Comment 1 Stephan Binner 2002-09-21 14:48:55 UTC
What ANSI sequences? And you exclude an error of you when the two best 
terminal emulators both show this behaviour? :-) 
Comment 2 Thomas Koeller 2002-09-21 14:56:56 UTC
Steps to reproduce: 
 
1. Start a bash shell inside konsole. 
2. Enter PS1="\e]2;\w\a\e[34;1m\! \s-\v \$\e[0m " 
3. Type a long line (contents do not matter). 
Comment 3 Stephan Binner 2002-11-02 21:03:16 UTC
Likely a bash problem. 
Comment 4 Elmar Stellnberger (AT/K) 2007-01-27 17:51:30 UTC
Even simple things like coloring the prompt will confuse konsole.
This is just too bad!
export PS1="\e[0;33m\u:\w> \e[0m"
Comment 5 Robert Knight 2007-01-27 19:13:00 UTC
The same results occur when entering that command sequence into gnome-terminal or xterm when using a BASH shell.  As far as I know gnome-terminal, Konsole and xterm all use different emulation code.

> The same behaviour can be observed with xterm, 
> so the problem obviously has been inherited from there

Konsole does not use any xterm code, so I shouldn't think this is the case.
Comment 6 Olivier Mengué 2007-03-09 15:36:03 UTC
This is not a bug in Konsole or xterm.

This is the shell that is confused about where it is, not the terminal.
You just have to properly configure your shell to ignore ESC sequences when counting characters that move the cursor.

With bash, just wrap ESC sequences with \[ and \].

For example:
  export PS1='\[\e[0;33m\]\u:\w> \[\e[0m\]'

With ksh, this is not as easy, but you can use '\015' to tell the shell from which char it must count characters.

The resolution of the bug must be INVALID instead of WONTFIX.
Comment 7 Olivier Mengué 2007-03-09 15:41:23 UTC
For reference, see the Bash FAQ <ftp://ftp.cwru.edu/pub/bash/FAQ>, question E3.
Comment 8 Elmar Stellnberger (AT/K) 2007-03-09 17:47:15 UTC
This is caused by libreadline, which is used by bash.
solution:
Enclose escape sequence by \[...\] to tell bash that it has zero length.
Comment 9 Bram Schoenmakers 2007-03-09 18:20:47 UTC
*** Bug 138413 has been marked as a duplicate of this bug. ***