From Bugzilla Helper: User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 2.0.50727; .NET CLR 1.1.4322) Description of problem: When I use escape character for coloring the bash command line it doesn't work as usual. It goes to the next line before reaching the last column. Also it start again from the same line. Version-Release number of selected component (if applicable): bash-3.0-31 How reproducible: Always Steps to Reproduce: 1. export PS1='[\e[31m\u\e[0m@\e[34m\h \e[32m\W\e[0m] ' It should change you bash to something like this: [mesgary@sib ~] while mesgary is red, sib is blue, ~ is green and other characters are white. 2. Try to write a command longer than one line, like: grep -e "ends with this$" `grep -li "have this" *` | grep -e "^starts with this" | grep -v "not having this" | less Actual Results: You will see that before you reach to the last column, it will start again from the first column but it didin't go to the next line. Expected Results: It continute to the last column, then go to next line and start from the first column. Additional info: It is because of the excape character used in the PS1. It seems that readline counts the number of character used in the PS1 by just removing the "\" character from the string. so it counts "e[31m", "e[0m", "e[34m", "e[32m" and "e[0m". and they are 23 characters. Also readline goes to the first column 23 columns befor etha last column in this example.
Of course it's a readline bug. readline-5.0-3
Not a bug. In bash, non-printing characters have to be marked with special characters \[ and \]. Correct is: export PS1='[\[\e[31m\]\u\[\e[0m\]@\[\e[34m\]\h \[\e[32m\]\W\[\e[0m]\] '