Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-unix!hplabs!tektronix!tekgen!tektools!jerryp From: jerryp@tektools.UUCP (Jerry Peek) Newsgroups: comp.unix.questions Subject: Re: Is there a Bourne-shell .logout script? Message-ID: <1950@tektools.UUCP> Date: Thu, 4-Dec-86 18:46:18 EST Article-I.D.: tektools.1950 Posted: Thu Dec 4 18:46:18 1986 Date-Received: Sun, 7-Dec-86 20:46:05 EST References: <502@cdx39.UUCP> <1051@ptsfb.UUCP> Reply-To: jerryp@tektools.UUCP (Jerry Peek) Organization: Tektronix, Inc., Beaverton, OR. Lines: 32 Keywords: logout exit Bourne shell In article <1051@ptsfb.UUCP> rob@ptsfb.UUCP (Rob Bernardo) writes: > In article <502@cdx39.UUCP> jc@cdx39.UUCP (John Chambers) writes: > >The C-shell runs a script called $home/.logout when you tell > >it to log you out. Is there any way to get the Bourne shell > >to do something similar? > > How about putting: > trap "$HOME/.logout" 0 > in your .profile (or in /etc/profile)? Not quite. Unless your Bourne Shell is different than mine (4.3BSD), this trap *starts a child Bourne Shell* to read the .logout file. This means that shell variables and stuff you've set in your login shell *won't be available* when the .logout file is read. On the other hand, in the C-shell, the .logout file is read *directly by the login shell*. This lets your .logout test for the presence of shell variables which were set in the login shell. For instance, I set up some shell variables that tell me whether the login shell came from a remote machine (rlogin) or not, and do different things in those cases. The fix is easy... use this "trap" instead: trap ". $HOME/.sh_logout" 0 The leading "." tells the login Bourne shell to read the ".sh_logout" file directly into itself, instead of spawning a child shell. (I name mine ".sh_logout" because it has Bourne-shell contents that csh would choke on.) --Jerry Peek, Tektronix, Inc. US Mail: MS 74-900, P.O. Box 500, Beaverton, OR 97077 uucp-style: {allegra,decvax,hplabs,ihnp4,ucbvax}!tektronix!tektools!jerryp Domain-style: jerryp@tektools.TEK.COM Phone: +1 503 627-1603