Fallback to home dir if initial working dir is inaccessible
In cases where the initial working dir is inaccessible by the current user, we should fallback to their home directory.
This can easily be triggered by changing the working dir to an otherwise inaccessible dir for the current user (e.g. /etc/sudoers.d inside a root shell), followed by opening a new session.
Edited by Christian Muehlhaeuser