$ bash -ec 'trap "echo rm lock" EXIT; echo lockfile; false' lockfile rm lock $ bash -ec 'trap "echo rm lock" EXIT; echo lockfile; . ./test.sh' lockfile bash: ./test.sh: line 3: syntax error near unexpected token `)' $ What a funny shit. I acquire lockfile, install exit handler, source something and then -- suddenly! -- the exit handler is not executed. Lockfile is left there forever. test.sh contains garbage: case f in a) a=1 b) b=1 esac
Compare this to ash: $ ash -ec 'trap "echo rm lock" EXIT; echo lockfile; . ./test.sh' lockfile ./test.sh: 3: Syntax error: ")" unexpected (expecting ";;") rm lock $
Seems to be fixed in bash-3.0
Fixed in 3.1.1-alt1
Fixed in 3.1.1-alt1.