bash 3.1 gotcha

Callum Lerwick seg at
Thu Jan 12 19:26:23 UTC 2006

For many years, I have had a fancy bash prompt, that contains this:
${PWD/#$HOME/~} This replaces your home dir with a tilde. However, with
bash 3.1, it stopped working:

seg at bigtime:/home/seg
$ rpm -q bash
seg at bigtime:/home/seg
$ echo ${PWD/#$HOME/~}

It works in bash 3.0 and earlier:

seg at hamburger:~
$ rpm -q bash
seg at hamburger:~
$ echo ${PWD/#$HOME/~}

I was very confused, until I figured out the ~ was now getting expanded
to $HOME, thus $HOME was getting replaced with $HOME! So escaping the
tilde fixes it:

seg at bigtime:~
$ echo ${PWD/#$HOME/\~}

I don't know if this is a bug or not. And may be too obscure for anyone
to care, but there it is.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <>

More information about the fedora-devel-list mailing list