Re^2: Identifying .login Shells

Maarten Litmaath maart at cs.vu.nl
Thu Feb 16 11:16:52 AEST 1989


dg at lakart.UUCP (David Goodenough) writes:
\From article <309 at wubios.wustl.edu>, by david at wubios.wustl.edu (David J. Camp):
\> Does anyone know a way to determine whether you are in the login shell
\> from .cshrc?  -David-

\In .cshrc say:

\set login=0

\and in .login say:

\set login=1

\Now

\if ($login == 1)

This doesn't work. Remember the question? "[...] determine [...] from .cshrc?"
								 ^    ^^^^^^
								 = in
My previous article is a general solution.
However, there's another thing to consider: you want to set some alias in
.cshrc - everytime a sub-csh is invoked -, but the alias depends on something
which is best executed once, in .login; how do you handle it?
My solution:

	# .cshrc
	if (! $?HOSTNAME) source ._login
	...

	# ._login
	setenv	HOSTNAME	`hostname`
	...

Note: it's `._login' instead of `.login', because there might be some other
statements in the latter that you don't want to get executed before the rest of
.cshrc has been executed. Furthermore .login would get executed twice [to be
prevented by another `if (! $?HOSTNAME)'].
-- 
 "Those who do not understand Henry     |Maarten Litmaath @ VU Amsterdam:
Spencer are condemned to reinvent DOS." |maart at cs.vu.nl, mcvax!botter!maart



More information about the Comp.unix.questions mailing list