Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uwmcsd1!marque!uunet!mcvax!hp4nl!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.unix.questions Subject: Re: Login shell? Message-ID: <830@philmds.UUCP> Date: 4 Oct 88 17:12:28 GMT References: <3ed799bc.103e8@hi-csc.UUCP> Reply-To: leo@philmds.UUCP (Leo de Wit) Organization: Philips I&E DTS Eindhoven Lines: 26 In article <3ed799bc.103e8@hi-csc.UUCP> mukul@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.