Using exit in a Bourne shell script

Dan Trottier dan at maccs.McMaster.CA
Tue Jul 26 22:32:14 AEST 1988


In article <16540 at brl-adm.ARPA> iunix1 at almsa-1.arpa (Will Martin) writes:
>Back in February, there were some Info-UNIX discussions under the above
>subject regarding methods of replacing the normal CTRL-D logoff with 
>a special script or procedure. One of the contributors mentioned this:
>
>> From: Kathy Vincent <kathy at bakerst.uucp>
>> 
>> 	trap '$HOME/.logout' 0
>> 
>> Which is to say, "when you receive the logoff signal, execute $HOME/.logout
>> first and THEN log off."
>
>Anybody have any advice on this subject? Is there a clean way to do what
>I want? Or even a dirty way -- I'm pretty sloppy... :-) Can a script
>executed at the "trap 0" point get back to the shell where the signal
>originated, or is it too late by then? If so, could it cause another
>top-level shell to be spawned, keeping all the environment I had before?

Here is how we do this around here. You must remember that your .login file
is read after reading your .cshrc file at login. In you .login file you
place the following "set ignoreeof" and in your .cshrc file you place 
"unset ignoreeof".

So at login the ignoreeof will be set by your .login file and thus will
prevent you from loging out via a ctrl-D. If you start a new sub-shell
the .cshrc file is read and the "unset ignoreeof" will allow you to use
ctrl-D to exit that shell.


Sorry if this has already been answered.

dan


-- 
       A.I. - is a three toed sloth!        | ...!uunet!mnetor!maccs!dan
-- Official scrabble players dictionary --  | dan at mcmaster.BITNET



More information about the Comp.unix.questions mailing list