I am using Linux Mint 19.2 Cinnamon, with ZSH as login shell for my user.
When I login, I see that my
$HOME/.local/bin two times, even though it is specified only once across all my ZSH startup scripts (in
I looked at the other dotfiles of my
$HOME, and found the offending modification of the
# set PATH so it includes user's private bin if it exists if [ -d "$HOME/.local/bin" ] ; then PATH="$HOME/.local/bin:$PATH" fi
This was surprising, because the documentation of ZSH says that
.profile is only sourced in a "compatibility" mode, when it is being invoked as
Zsh tries to emulate sh or ksh when it is invoked as sh or ksh respectively; more precisely, it looks at the first letter of the name by which it was invoked, excluding any initial 'r' (assumed to stand for 'restricted'), and if that is 'b', 's' or 'k' it will emulate sh or ksh. Furthermore, if invoked as su (which happens on certain systems when the shell is executed by the su command), the shell will try to find an alternative name from the SHELL environment variable and perform emulation based on that.
I checked from where
.profile was being source from by appending the following lines at the end of it:
logger "Opened .profile with this shell: $SHELL" PARENT_COMMAND=$(ps -o args= $PPID) logger "Parent command: $PARENT_COMMAND"
After logging out and logging back in again, the syslog contained the following:
Opened .profile with this shell: /usr/bin/zsh Parent command: lightdm --session-child 13 20
What is the sequence of events that leads the display manager
lightdm to source
.profile even though my
$SHELL is ZSH, and what is the rationale behind it?