On May 15, 2013, at 10:30 AM, Jason Merrill <ja...@redhat.com> wrote: > In my testing, bash seems to consistently run the 0 trap when it exits due to > a signal; are there other shells that don't?
trap 0 is for every exit case, normal, error, abnormal. This is why you'd see two removals if you used 0 and any other number. trap 0 is a newism, it didn't work in 1986 on AT&T's /bin/sh for example. It also suspect it didn't work on bash in 1987 for example. Now, is it portable enough. I'd probably just use it and go on with life. If there are real systems that it fails on that are important, they can add 5 lines to the script and fix it. http://www.gnu.org/software/autoconf/manual/autoconf.html#trap has a ton on trap 0, and much of it is scary and unfortunate. >> the script is ran with $(SHELL), which IIRC is typically /bin/sh, not >> necessarily bash. > > I thought that 'trap' was specific to bash; now that I see it's part of > POSIX, I'll make the rest of the script more portable. Nope, trap predates both bash and posix. trap 0 is new fangled (I think it was first new in ksh, before posix).