Login shell?
Kris Croes
croes at imec.uucp
Wed Oct 12 00:25:15 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.
The following is not exactly an answer to this question (Chris Torek
answered it exactly in article <13851 at 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.
More information about the Comp.unix.questions
mailing list