2

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?

11
  • 1
    What is a "non-interactive login shell"? Isn't that an oxymoron? How exactly are you invoking zsh? I'm guessing your zlogout wasn't getting sourced because you weren't actually in a login shell. Zsh's docs are a bit sparse about login vs non-login shells compared to bash's docs on the topic.
    – Spiff
    Commented Apr 21 at 21:54
  • @Spiff A non-interactive login shell is rare, but if you run a command as shown in my post, or like bash -lc 'echo $-' it is a login, but non-interactive. I checked if I was in a login shell by running echo $-, which printed an i, using zsh.
    – Silas
    Commented Apr 24 at 9:01
  • Thanks for your time so far @Spiff ! I believe we might have a miscommunication. I do not use sudo. Following your advise, I adopted the command in my original post to be this: 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.
    – Silas
    Commented Apr 25 at 20:36
  • Oops my bad. You wrote su and my brain read sudo.
    – Spiff
    Commented Apr 25 at 21:18
  • I bet that it is not a login shell. Do a echo $- to find out. If the string contains a l (lower case L), you have a login shell. Commented May 2 at 13:57

0

You must log in to answer this question.

Browse other questions tagged .