Is there a Bourne-shell .logout script?

cgs at umd5.UUCP cgs at umd5.UUCP
Wed Dec 10 05:48:32 AEST 1986


In article <1950 at tektools.UUCP> jerryp at tektools.UUCP (Jerry Peek) writes:
>In article <1051 at ptsfb.UUCP> rob at ptsfb.UUCP (Rob Bernardo) writes:
>> In article <502 at cdx39.UUCP> jc at 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.
>
> ...
>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.)
>

Unless your "man page" for "sh" is different than mine (4.3BSD),
the first trap will perform the function desired, while 'trap ". foo" 0'
will execute the file 'foo' AND RETURN when signal 0 is encountered. See
the section entitled "Special Commands".

-- 
--==---==---==--
.. And hast thou slain the Jabberwock? ..

ARPA: cgs at umd5.UMD.EDU     BITNET: cgs%umd5 at umd2
UUCP: ..!seismo!umd5.umd.edu!cgs



More information about the Comp.unix.questions mailing list