Sample Header Ad - 728x90

Bash misinterpreting lenght of PS1 when using ANSI escape sequences

0 votes
0 answers
35 views
if i use the following
export PS1='\033[36m$ \033[0m'
Bash misunderstands the length of the prompt and starts line-wrapping too early. My assumption was that it is counting every character, but comparing ${#PS1} to $COLUMNS shows that not to be the case. if i instead use the following
export PS1='$ '
there is no issue additionally, if i use dash shell, this does not happen, so i know it is an issue with Bash, and not my terminal etc. however, if i launch dash in vi mode with dash -V or set -o vi, the escape characters are ignored and not sent to my terminal at all. I assume this is a bug in dash though, so i reported this on the dash mailing list. thanks
Asked by user21749640 (101 rep)
Aug 20, 2024, 09:17 PM