Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!bu-cs!purdue!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!prlb2!kulcs!kulesat!imec!croes From: croes@imec.uucp (Kris Croes) Newsgroups: comp.unix.questions Subject: Re: Login shell? Summary: Detection of "source .cshrc" Message-ID: <511@imec.UUCP> Date: 11 Oct 88 14:25:15 GMT References: <3ed799bc.103e8@hi-csc.UUCP> <13851@mimsy.UUCP> Reply-To: croes@imec.UUCP (Kris Croes) Organization: IMEC, INTERUNIVERSITY MICROELECTRONICS CENTER, BELGIUM Lines: 39 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. The following is not exactly an answer to this question (Chris Torek answered it exactly in article <13851@mimsy.UUCP>), but it is related and useful too. A way to detect whether your .cshrc is executed the first time, or whether it is executed with a "source .cshrc" e.g. after you edited it is: < 1> # Test if new csh. < 2> set temp = /tmp/prompt$$ < 3> history 1 > $temp < 4> if (-z $temp) then < 5> # This is the first time .cshrc is executed < 6> alias lpr `which lpr` \!\* \& < 7> else < 8> # This is when .cshrc is executed with 'source' < 9> endif <10> /bin/rm $temp <11> unset temp Why is this usefull? A little example: When no precautions are taken, on some machines the `which ...` on line 6 would return "alias: /usr/local/lpr !* &" when you source your .cshrc. From then on, you need paper and a pencil to make listings. 8-) Hopefully someone can use it... Kris Croes. -- -------- K. CROES - IMEC - Leuven - Belgium ..!prlb2!imec!croes The Demon King sends a "rm -r /" to your shell.