You have not defined βsafeβ exactly, but one element of it should probably be cleared after you.
trap "rm -f \"$tmpfile\"" 0 1 2 3 15
You can probably man 3 signal see if there are other signals that could erase the temp file. A zero signal means "clean output."
ghoti
source share