Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!hplabs!sdcrdcf!sdcsmb!grand!eggert From: eggert@grand.sm.unisys.com (Paul Eggert) Newsgroups: comp.unix.wizards Subject: Re: sh(1) traps & exit status Message-ID: <20@grand.sm.unisys.com> Date: Mon, 2-Nov-87 21:21:47 EST Article-I.D.: grand.20 Posted: Mon Nov 2 21:21:47 1987 Date-Received: Fri, 6-Nov-87 23:52:28 EST References: <1639@uqcspe.OZ> Reply-To: eggert@grand.sm.unisys.com (Paul Eggert) Organization: Unisys Santa Monica Lines: 9 In article <1639@uqcspe.OZ> tony@uqcspe.oz (Tony O'Hagan) writes: |I hate having to assign the exit status to a variable before every exit. |This doesn't work: | trap 'ts=$?; rm -fr $tdir; exit $ts' 0 1 2 3 15 You are springing the trap twice. Use this instead: trap exit 1 2 3 15 trap 'ts=$?; rm -fr $tdir; exit $ts' 0