Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: global zlogout and .zlogout



> I meant to say the global zshenv, not the global zlogin.  But the more I
> think about it, I'm no longer happy with this idea.  There should be
> someway to suppress the sourcing of the global zlogout.  But you don't
> want users to be able to do this.  I believe it was Zoltan who mentioned
> sourcing the global zlogout only if the global zlogin was sourced.  That is
> easy to do.  Before anything is changed, I would like to know for what
> purposes are people using the global zlogout file.

The is no way to prevent the user to avoid the global zlogout.  Anyone can
exit the shell with kill -9 $$.  One can even put kill -9 $$ into her .zlogout
which is executed before the global zlogout.  That's why I think that we can
use no_rcs to decide whether zlogout should be executed or not.

> >  >Also, I now realize another potential problem.  When the init scripts
> >  >are sourced when the shell is starting up, there is a hack (setting the
> >  >sourcelevel to 32768) that prevents an error in these scripts from tripping
> >  >ERREXIT.  This same should probably apply to the global zlogout and .zlogout.
> > 
> > Only to the global one. The user's one is his problem.
> 
> ERREXIT is suppressed for all the init script (both global and personal).
> Seems like the same should be the case for the global zlogout and .zlogout.

That's right.  But this is because an errexit during the init scripts may lock
out a user from her shell.  An init script should not exit to give a chance to
the user to correct her mistake.  In logout scripts there is no such danger I
think but as you said it depends on the function of the global zlogout script.

But there are other things which can be changed here.  Currently the order of
sourcing in a login shell is:

GLOBAL_ZSHENV, .zshenv, GLOBAL_ZPROFILE, .zprofile, GLOBAL_ZSHRC, .zshrc,
GLOBAL_ZLOGIN, .zlogin

This means that a clever user can avoid every global init scripts except the
GLOBAL_ZSHENV.  So everything which must be executed should be put here.  But
we must keep it small and fast since it is executed on all zsh invocations.
One solution may be to execute all of the user init scripts after the global
ones.   The global zlogin can be an exception here since zprofile has similar
functions.

Cheers,
  Zoltan



Messages sorted by: Reverse Date, Date, Thread, Author