Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug with long color prompt + long command line?

4 views
Skip to first unread message

slinkp

unread,
May 19, 2008, 3:50:40 PM5/19/08
to
I know the presence of "color" in my subject will cause people to tell
me to read
the FAQ section E3; so I already have ;-)

Here's how I can reproduce:

1) set PS1 to use colors and reset the color at the end, as per the
bash
prompt HOWTO; eg. the "lightweight" prompt described here,
http://www.gilesorr.com/bashprompt/howto/x924.html

For example, here's my preferred prompt:
PS1="\[\033[01;32m\]\u@\h\[\033[01;34m\] \W \$\[\033[00m\] "
As far as I can tell, everything is escaped properly... no?

2) cd to a directory with a name that is longer than $COLUMNS
e.g. if COLUMNS == 80, something like this:
mkdir \
reallylongname1345678901234567890123456789012345678901234567890123456789012345678901234567890

cd \
reallylongname1345678901234567890123456789012345678901234567890123456789012345678901234567890

3) type a command line longer than $COLUMNS; just enter random
characters
until it wraps. But don't hit enter, instead hit Ctrl-a (or Esc-0
if you prefer vi)

Expected: The cursor moves to the beginning of the command line.

Observed behavior: The cursor is displayed several characters after
the beginning of the line, but edits behave as if you ARE at the
beginning of the line, so what you see is not what you get, and
editing the command line becomes almost impossible.

I can reproduce this at the console or in any terminal I've tried
(xterm, rxvt, gnome-terminal, ...)

I checked with several coworkers and they can reproduce this too.

Note that I don't get this problem if I leave out the color reset at
the end of the prompt; eg this works fine:
PS1="\[\033[01;32m\]\u@\h\[\033[01;34m\] \W \$ "

Workarounds:

- don't use a color prompt

- or, don't display \W or \w in the prompt


Can anybody confirm if this is a real bug?

Oh yeah:

$ bash --version
GNU bash, version 3.2.33(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.

Thanks,

- Paul Winkler

slinkp

unread,
Jun 2, 2008, 10:58:47 AM6/2/08
to
Just wondering about the lack of response...

- Maybe nobody had time to look into this? (likely)

- nobody cares since it's really only a problem with the combination
of \w and color prompts?
(With \W it only happens with an artificially long directory name as
in my example.)

- Maybe this is a repeat of old thread(s)?
Well, I did find one similar thread
http://groups.google.com/group/gnu.bash.bug/browse_thread/thread/68274b1c434bd541/d2760d11300ff621?lnk=gst&q=color+%5Cw#d2760d11300ff621
...which roughly went like:
- someone reports a problem with line wraps and color prompts
- everybody says "read the FAQ section E3/E5 (depending on version)"
- the original poster says "okay I've properly escaped my prompt
according to the FAQ, but there are still problems"
- no further replies.

I also found this, from 1999(!) which looks closer to my problem, with
no replies at all:
http://groups.google.com/group/gnu.bash.bug/browse_thread/thread/ba19c607d66bc79e/19ca0e35378d7c2d?lnk=gst&q=color+%5Cw#19ca0e35378d7c2d

What I have not found anywhere is either a pointer to documentation
that actually fixes the problem (sorry for being redundant but the
instructions in the FAQ do *not* fix this problem), or an
acknowledgment that there is a problem in bash.

Thanks,


- PW

(rather than quote my entire previous post here's a link:
http://groups.google.com/group/gnu.bash.bug/browse_thread/thread/9da7e81b060d77d4
)

Chet Ramey

unread,
Jun 2, 2008, 3:14:55 PM6/2/08
to st...@slinkp.com, bug-...@gnu.org, ch...@po.cwru.edu
> - Maybe nobody had time to look into this? (likely)

It took a while, but I did look at it and fix the problem. The fix will
be in bash-4.0, and maybe in a patch to 3.2, depending on timing.

> according to the FAQ, but there are still problems"
> - no further replies.

Because I released a patch that fixed it.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU ch...@case.edu http://tiswww.tis.case.edu/~chet/


slinkp

unread,
Jun 2, 2008, 3:38:33 PM6/2/08
to
Great to hear it! Thanks very much Chet.
0 new messages