[gnu.bash.bug] bug with long prompt strings containing newlines

jjd@ALEXANDER.BBN.COM (James J Dempsey) (10/07/89)

[ bash 1.03, Sparcstation-1, SunOS 4.0.3c, gcc 1.35, yacc ]

I like to know what my current directory is all the time.  When I'm
using X (which is usually) I have a PROMPT_COMMAND which puts the
current directory (and hostname) in the title bar of the xterm window.
However, when I'm dialing in from home, I set my PS1 to something like
this:

export PS1="\w \t\n\h $ "

which ends up printing a prompt something like this:

/usr/jjd 12:35:13
underdog %

which is fine except when the current directory gets too long.
Whenever bash tries to do editing, it gets confused about the length
of the prompt.  It thinks that the prompt is the length of the string
PS1 without taking into account the \n characters.  It should consider
the length of the prompt to be the number of characters (after
expansion) after the last \n.

To reproduce this bug try this:

PS1='012345678900123456789001234567890012345678900123456789001234567890\n$ '

(that's sixty characters followed by a newline, a dollarsign and a space)

Then at the prompt type abcdefghijklmnopqrstuvwxyz followed by a ^A.
When bash tries to reposition the cursor following the ^A command, it
will get confused because it thinks the prompt is 63 characters
instead of two.

		--Jim--