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

Re: [[ -o interactive ]] vs if [[ -o login ]]?



On Aug 14,  6:46pm, TJ Luoma wrote:
}
} if [[ -o interactive ]]
} if [[ -o login ]]
} 
} Are they two ways of saying the same thing? If not, could someone
} explain the difference?

Unless someone is playing games with the command-line switches when
starting zsh: 

[[ -o interactive ]] is always true when [[ -o login ]] is true.

But

[[ -o login ]] is NOT always true when [[ -o interactive ]] is true.

(That is, you can forcibly "zsh -o nointeractive -o login" but that
will never happen in ordinary usage.)

As far as the shell itself is concerned, the only difference is in
whether the ~/.zlogin and ~/.zlogout files are read at startup and
normal exit, respectively.  (And their /etc/ counterparts, too.)

At a larger level, it's usually the case that login shells are those
started directly by the OS when a user logs in on a terminal, whereas
interactive shells are those started indirectly from a login shell.
The advent of windowing systems, however, often means that there is
no single login shell and it's up to the configuration of the terminal
emulator whether a shell started in a window behaves as a login shell.

The intent is that certain environment setup can be done once when the
user first logs in, and then not done again.  Under a windowing system,
the session manager is usually responsible for that one-time setup, but
for remote shells it may still be useful to have the shell do it.

Typically login shells have an entry in the utmp database (the output
of the "who" command) and other shells do not, but again that's up to
the process that started the shell, not the shell itself.

-- 



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