4

I'm trying to fix a curious problem I'm having with bash prompt (PS1) manipulation, and I'm very confused as to why \W is re-writing 'pwd' improperly in my case.

user@server-01:/repo$ PS1='${debian_chroot:+($debian_chroot)}\u@\h:\W\$ '
user@server-01:rpoo$
user@server-01:rpoo$ PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
user@server-01:/repo$

The following / directories show up weird:

/boot = bott
/home = hmee
/lib32 = li332
/lib64 = li664
/media = meiia
/proc = pocc
/repo = rpoo
/sbin = sinn

What I'd like to know is why is '\W' showing 'rpoo' instead of 'repo', and the others above... '\w' on the other hand displays the full path and correct names as expected?! I'm not doing anything very complex with my prompts, and I have a 'facter' dependency statement in my bash prompting, but even going back to the defaults I still see this funky substitution. This is a git repository directory, but that shouldn't have anything to do with it. I have this problem only on a two of three servers that hold this repository, other servers with the same bash.bashrc file work and operate fine, without this kind of \W funky substitution. Freshly deployed systems with this same prompt are OK.

I tried to search for how or what \W was being set to with no success, but \w is not behaving the same. Any help on tracing this thing down???

  • 1
    Notice the pattern. It looks like the name, and then overlaying it is the last two letters of the name backed up by two positions. I'd look for backspaces or something in the output. – Paul Tomblin Sep 10 '12 at 19:17
  • Seems I might be affected by http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=590052, but that seems way old to be affecting me today. – user1660984 Sep 10 '12 at 20:35
  • What does "bash --version" tell you? – Paul Tomblin Sep 10 '12 at 20:40
  • GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu) – user1660984 Sep 10 '12 at 20:42
  • 1
    Well, that bug fix you posted a link to says it was fixed in bash version 4.2-1. So why don't you think it's affecting you in 4.1.5? – Paul Tomblin Sep 10 '12 at 20:44
  • because not all of my systems do this... and considering how old this bug is I would have expected it to be resolved long ago. Not all my debian systems exhibit this problem. 'root@puppet-01:~# bash --version` `bash --version` `GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)` `root@host-01:~# cd /boot` `root@host-01:/boot# cd /home` `root@host-01:/home#` So it perplexes me that I'd have to update bash... when there's no debian update for bash on stable/squeeze (infact, it still lists version 4.1-3 and not 4.1-5. – user1660984 Sep 10 '12 at 20:52
  • The bug report also says that it's not happening everywhere all the time. There is no indication that the bug is fixed in Debian. – tripleee Sep 10 '12 at 21:15
  • Do you have anything in `PROMPT_COMMAND`? Try `uniname -bcp ~/.bash* | grep BACKSPACE` or `env | uniname -bcp | grep BACKSPACE`. – l0b0 Sep 11 '12 at 11:00
  • 2
    The bug was reported in 4.1.3 and fixed in 4.2.1. That means it's also found in every version in between those two. And Debian is not known for speedy updates. :) – Mark Reed Sep 19 '12 at 03:02

0 Answers0