Login shell?
Leo de Wit
leo at philmds.UUCP
Wed Oct 5 03:12:28 AEST 1988
In article <3ed799bc.103e8 at hi-csc.UUCP> mukul at hi-csc.UUCP (Mukul Agrawal) writes:
|Is there a way ( /bin/csh , Sun Unix 3.4 ) to find out if the shell
|that is running is a login shell or not, just like one can use
|"$?prompt" to find out whether or not it is an interactive shell.
Don't know whether there is a standard way; at least the csh seems to
know whether it is a login shell or not - try for instance 'login' in a
not-login shell (probably done by inspecting the parent process id;
even if you exec a login shell by a new shell it is considered a
not-login shell, so this seems also to point to process ids).
If you don't have to use it on a system-wide basis (what I mean is this
solution is reliable as far as the user is reliable) you can solve your
problem with this little trick: put into your ~/.login a line:
set login_shell
As .login is sourced only by the login csh, the presence of this shell
variable can now be tested to find out whether you're dealing with a
login shell. Something similar can be done for the Bourne shell,
putting this variable in the $HOME/.profile (e.g. login_shell=1 ); in
this case you must not export the variable so that it won't be
inherited into the environment of subsequent shell invocations.
I hope this help -
Leo.
More information about the Comp.unix.questions
mailing list