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

bash 3.1 gotcha



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 bigtime:/home/seg
$ rpm -q bash
bash-3.1-2
seg bigtime:/home/seg
$ echo ${PWD/#$HOME/~}
/home/seg

It works in bash 3.0 and earlier:

seg hamburger:~
$ rpm -q bash
bash-3.0-31
seg 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 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.

Attachment: signature.asc
Description: This is a digitally signed message part


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