bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble with PS1 special characters between \[ and \]


From: Lluís Batlle i Rossell
Subject: Re: Trouble with PS1 special characters between \[ and \]
Date: Tue, 9 Nov 2010 23:32:57 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

On Sun, Oct 31, 2010 at 09:24:24PM +0800, Clark J. Wang wrote:
> 2010/10/31 Lluís Batlle i Rossell <viriketo@gmail.com>
> 
> > Hello,
> >
> > I don't think this problem is related to any recent bash version only. I've
> > seen
> > this since years I think.
> >
> > Nevertheless I'm using GNU bash, version 4.0.17(1)-release
> > (x86_64-unknown-linux-gnu) now.
> >
> > My PS1 uses the "Change window title" sequence, to set the xterm window
> > title to
> > something close to the prompt text. Hence my PS1 is:
> >
> > PS1='\[\033]2;\h:\u:\w\007\]\n\[\033[1;31m\][\u@\h:\w]\$\[\033[0m\] '
> >
> > The ESC ] 2;.....BEL command, which has \h, \u and \w sequences in the
> > middle,
> > has problems on the length of the printable part of the prompt, as those
> > usual
> > when typing terminal control sequences without \[ \]. With the difference
> > that I
> > typed all the \[ \].
> >
> > May bash be having trouble, if it finds any of its own special backslash
> > characters (\h, \u, \w) in the middle of a non-printable sequence marked
> > with \[
> > and \] ?
> >
> 
> My understanding is that chars enclosed between \[ and \] are considered by
> Bash to be of zero-length.

Sorry for answering late. I read the code, and I saw how bash works with \[ and
\] and passes them to readline. So now I think the problem is in readline.

My problems appear when I have that coloured prompt, and I have a window thiner
than the prompt, so the prompt becomes multiline, but with only one or two
characters in the second line. Then the editing gets weird.

I read a bit the readline code, and for the little I understood on the invisible
prompt multibyte characters, it may be that it does the job wrong for the case
"not the first line". The code looks written like cosnidering the "first line".

I asked at irc.freenode.net#bash, and there people could reproduce it. I'm now
using bash 4.1.2(1) with readline 6.1 and I can reproduce it.

Thank you,
Lluís.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]