This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

readline clash with bash/PS1 escapes


Hi,

After a recent cygwin update (including one just today), I'm seeing a bug
in the readline completion that I finally tracked down to the control
sequences in my PS1 for setting the title bar and coloring my prompt.  It
looks like the '\[' and '\]' delimeters are screwing it up.  Here are the
symptoms (~> is my prompt).

  ~>env | fgrep PS1
  PS1=\[\033]0;\W\007\]\[\033[32m\]\w>\[\033[0m\]

When I type: ls .<tab><tab>
I see:
----------------------------
  ~>ls .
  ./             .bash_history  .cvsrc         .ssh/          .vimrc
  ../            .bash_profile  .history       .vim/
  .Xdefaults     .bashrc        .inputrc       .viminfo
  ~>ls . .
----------^-----------------
Notice the extra " ." in the re-rendered line (^ indicates the prompt
position).  Something is clearly out of sync.
For example, if I then type: Control-U
I see:
----------------------------
  ~>ls .
  ./             .bash_history  .cvsrc         .ssh/          .vimrc
  ../            .bash_profile  .history       .vim/
  .Xdefaults     .bashrc        .inputrc       .viminfo
  ~>ls
----^-----------------------
where the prompt is overlapping the "ghost" letters "ls", which aren't
really in the buffer.  E.g., if I then type: p<enter>
I see:
----------------------------
  ~>ls .
  ./             .bash_history  .cvsrc         .ssh/          .vimrc
  ../            .bash_profile  .history       .vim/
  .Xdefaults     .bashrc        .inputrc       .viminfo
  ~>ps
  bash: p: command not found
  ~>
----^-----------------------
After some experimentation, I found that if I removed the '\[' and '\]'
delimiters from my PS1, the errant behavior goes away.  The
control sequences evidently still work, even though the man page for bash
suggests that they really should be enclosed within \[ \].

Suan

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]