[Top][All Lists]

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

Prompt length calculation fails when UTF-8 is used within \[ \]

From: Lasse Kärkkäinen
Subject: Prompt length calculation fails when UTF-8 is used within \[ \]
Date: Wed, 15 Jul 2009 04:10:35 +0300
User-agent: Thunderbird (X11/20090608)

Steps to reproduce: (using UTF-8 locales)

$ export PS1="\[\e]2;test Ä and Ö here\a\]prompt>"
prompt>abcdefgh    # Enter some alphabets and press Home
     ^ Cursor goes here, instead of
       ^ here where it should go.

Add more UTF-8 letters as non-printable characters in PS1 and the offset from the correct position gets bigger. Here it was two characters because of two "extra" bytes in the UTF-8 put in there.

I noticed that you have to type a right amount of characters to make Home key use the calculated prompt length. abcdefgh seems to work in this case, but if the prompt is modified, you may need to type more or less than that to see the effect.

Tested with versions:
GNU bash, version 4.0.0(2)-release (x86_64-unknown-linux-gnu)
GNU bash, version 3.2.48(1)-release (x86_64-pc-linux-gnu)

reply via email to

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