My ~/.zlogout
contains the following:
echo '~/.zlogout!'
Let's run the following script:
su user -ls /bin/zsh -c 'echo kaasbier; exit'
Nothing is echoed (besides the kaasbier
). I am testing this in a vanilla archlinux VM.
Even if I do not run exit
but logout
, I still cannot trigger the logout script to be sourced. It does work, when exiting an interactive mode: su user -ls /bin/zsh
.
Thus, why is ~/.zlogout
(or /etc/zlogout
) not sourced upon exiting an non-interactive login shell?
bash -lc 'echo $-'
it is a login, but non-interactive. I checked if I was in a login shell by runningecho $-
, which printed ani
, using zsh.su user -ls /bin/zsh -c 'setopt'
. This does print 'login'. Thus, I believe to correctly invoke my shells as login. This means that in the example in my post, the logoout script should have been sourced on exit - as far as I understand things.echo $-
to find out. If the string contains al
(lower case L), you have a login shell.