Bug 148844

Summary: terminal text wrapping bug
Product: [openSUSE] SUSE Linux 10.1 Reporter: Jeff Stedfast <fejj>
Component: BasesystemAssignee: Dr. Werner Fink <werner>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: dickey, dickey, sndirsch, suse-beta, werner
Version: Beta 3   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Jeff Stedfast 2006-02-07 20:58:35 UTC
This affects at least xterm and gnome-terminal

when you first open gnome-terminal or xterm and type a really long command-line (one which would wrap), instead of wrapping to the next line, it wraps on the same line thus appearing to overwrite text you've already typed.

it seems this problem goes away after you hit return and then type a second really long command-line, so it's important to open a fresh xterm/gnome-term to test this.
Comment 1 Michael Gross 2006-02-08 12:39:46 UTC
I can confirm that. But I don't think this was found in B4 as B4 is not released yet ;)
Setting to major because this is really ugly.
Stefan: Please take care about that.
Comment 2 Stefan Dirsch 2006-02-08 13:38:36 UTC
Also happens with xterm on 10.0. Nobody complains about this before. Cannot be that important. Setting to NORMAL again.

Werner, Thoams, any ideas?
Comment 3 Thomas Dickey 2006-02-08 22:37:31 UTC
This has been reported in Debian as a problem with bash.
Look at #343471 and #34811.
Comment 4 Stefan Dirsch 2006-02-08 23:04:20 UTC
Indeed. Assigning to our bash maintainer.

--> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=343471

BTW, Debian Bug #34811 does not exist.
Comment 5 Thomas Dickey 2006-02-08 23:37:18 UTC
sorry: 348111
Comment 6 Dr. Werner Fink 2006-02-09 10:12:49 UTC
I'm not able to reproduce this.  Please provide the exact terminal settings
with the output of `stty -a'.
Comment 7 Dr. Werner Fink 2006-02-09 10:20:21 UTC
Seems to be a problem of what is done during setting the prompt.
With my prompt it never occurs with some other prompts it happens
only the very first time and I've here a user around who has a
special PROMPT_COMMAND and with this it happens on every line.
Comment 8 Dr. Werner Fink 2006-02-09 10:26:33 UTC
My personal prompt:

  tmp$ echo $PS1
  \[\e]2;\u on \h: \w\007\e]1;\h\007\]\W$

the PROMPT_COMMAND

  werner@fatou:/tmp > PROMPT_COMMAND='PS1=`if test "$UID" = 0 ; then \
      echo -e "\[\033[31m\]\h:\`pwd -P\` #  \`tput sgr 0\`\033[m\017"; \
  else \
      echo -e "\[\033[32m\]\u@\h:\`pwd -P\` > \`tput sgr 0\`\033[m\017"; \
  fi `'

Thomas? I'm not sure if this is really a bash bug :)
Comment 9 Dr. Werner Fink 2006-02-09 11:08:32 UTC
OK for the PROMPT_COMMAND I've a solution to say the bash to send
escape sequences to the terminal and not to write them onto the
prompt output:

  PROMPT_COMMAND='PS1=`if test "$UID" = 0 ; then \
      echo -e "\[\e[31m\]\h:\`pwd -P\` #  \[\`tput sgr 0\`\e[m\017\]"; \
  else \
      echo -e "\[\e[32m\]\u@\h:\`pwd -P\` > \[\`tput sgr 0\`\033[m\017\]"; \
  fi `'

this is done by the special prompt command sequences \[ ... \].

Now we need to now at which point at xterm start escape sequences will
be written to the prompt output instead to the terminal.
Comment 10 Dr. Werner Fink 2006-02-09 11:14:59 UTC
Hmmm ... read last sentence with s/now/know/
Comment 11 Christian Boltz 2006-02-09 11:39:56 UTC
(In reply to comment #8)

It's most likely a problem with the escape sequences - you have to mark them as non-characters so they don't get counted. Unfortunately, I don't really understand what your tput command does.

If you use "invisible" characters like escape sequences for changing the color, you always need   \[ ... \]   around them.

However: Try
    PS1='\[\e[32m\]\u@\h:`pwd -P` > \[\e[0m\]'
which should give you the same (user) prompt if I get it right.

And have a look at http://www.cboltz.de/de/linux/bashprompt/?bnc (german) or http://www.cboltz.de/de/linux/bashprompt/?bnc (english) for a "cheaper" *) way to switch the prompt for root ;-)

*) "cheaper" because it is done once at login - not every time the prompt is 
   shown.


For those who only see the problem in the first line of a freshly started bash: please run   script bash-init   - then hit enter twice and call "exit". You can then check the file  bash-init  for the escape sequences used - I guess there will be some additional sequences in the very first prompt.
Comment 12 Dr. Werner Fink 2006-02-09 12:37:44 UTC
I've a workaround.  A simple line

       unset TERMCAP

within the /etc/bash.bashrc and we're gone.
It seems that within the source code a

       if (interactive_shell && no_line_editing == 0)
          rl_reset_terminal (get_string_value ("TERM"));

is missed.
Comment 13 Dr. Werner Fink 2006-02-09 12:50:31 UTC
I've add this workaround to get it fixed for now.
Comment 14 Christian Boltz 2006-02-14 20:48:33 UTC
*** Bug 150833 has been marked as a duplicate of this bug. ***