The commands 'cd $PWD' and 'cd .' in bash both look like useless no-ops which change into the same directory you're already in. But they're not, and both can be useful.

$PWD is a string variable which caches the pathname that your current directory had at the time you changed into it. It's not automatically updated in between cd commands.

So 'cd $PWD' (or 'cd "$PWD"' if you're being properly careful) changes to whatever directory _now_ lives at the pathname that your actual cwd _was_ when you changed to it.

'cd .' really _does_ just change directory to the same physical directory you're already in, but it's still not useless, because it causes bash to recalculate the value of $PWD.

For example, if one shell is in ~/test, and in another shell you rename ~/test to ~/newname and make a new directory ~/test, then in the first shell 'cd $PWD' will move to the new ~/test, whereas 'cd .' will stay in the original directory but update $PWD to reflect the fact that it now lives at ~/newname.

@simontatham Also one case where I use cd . rather frequently is going into a folder, realizing I forgot to mount it, fix that, and then cd . to then actually go in the mounted filesystem.
@simontatham @lanodan cd "$PWD" because I’m a few directories inside if a thing that got umounted/removed and recreated (e.g. chroots from the outside)…
@mirabilos @simontatham I think I cd . as well when git rebase removes the directory I'm in only to re-create it right after.
@simontatham @lanodan ah ok, if it works…
@mirabilos @simontatham Yeah not entirely sure how but well it's short and easy to type.
@lanodan @simontatham I actually type cd $PWD + Tab + Enter, as #mksh tab-completes shell parameters in backslash-escaped form (so no splitting), which is easy to type (right tiny finger lies on shift while I press $WD with left hand and P with right pointing finger)