Path: utzoo!attcan!uunet!husc6!mailrus!uflorida!umd5!brl-adm!adm!iunix1@almsa-1.arpa From: iunix1@almsa-1.arpa (Will Martin) Newsgroups: comp.unix.questions Subject: Re: Using exit in a Bourne shell script Message-ID: <16540@brl-adm.ARPA> Date: 19 Jul 88 01:43:30 GMT Sender: news@brl-adm.ARPA Lines: 36 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 > > trap '$HOME/.logout' 0 > > Which is to say, "when you receive the logoff signal, execute $HOME/.logout > first and THEN log off." On our Sys V Unisys/Sperry I can do this, and get the ".logout" script to execute when I hit a CTRL-D at the shell. It runs whatever I put in ".logout" and then logs me off the system. However, what I really want to happen is to have a script execute that will then ask me "Do you REALLY want to log off?" and then either return me to my shell, or allow me to log off, depending on my answer. I want to do this because I am constantly spawning subshells to do this or that task, and using CTRL-D to end them. I often hit a CTRL-D at my top-level shell and get logged off when I really did not want to log off -- I thought that I was under my message-reading program, for example, and wanted to get back to it. So I am willing to take the extra time to confirm it when I am finally done and really, truly want to log off. I had thought at first that I could do something with stty "eof" or suchlike settings that could make my actual logoff character someting other than CTRL-D, so I could use that to kill subshells, but not my top-level shell, but I've been told that won't work. 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? Will Martin "wmartin@almsa-1.arpa"