Let's say we have ./a
and ./b
directories. Then we create a symlink using ln -s a x
and entering it cd x
The pwd
would be x
Then in another terminal we change the x
so that it pointed to b
. But the first one would still return x
for pwd
which is not consistent anymore.
So is there a way for current terminal (bash) to alert/warn if the current path is the obsolete symlink?
Best Answer
Here's an approach which uses the fact that bash does command expansion on
$PS1
to test to see if.
and$PWD
have the same inode in the prompt: