trap is a setjmp/longjmp type outcome. You pop up in a
call you didn't
exactly "plan" for (well you did: you wrote it. But you don't know the
entry state which led you there, unlike normal program flow) -well, it
is.. because you get there.
I once won a Usenix contest for using /bin/sh to test your reflexes.
trap "ls | wc ; exit 0" 0 1 2 3 15
ls * | wc -l
echo "Type ^C; see how close you can make your number match"
rm -rf * | wc -l
kill -1 $$ # For those without "trap 0"