Cleaning Up Temp Files
A script creates tmp=$(mktemp -d). How do you make sure it's removed when the script ends, also on errors?
tmp=$(mktemp -d)
Choose one answer
Put rm -rf "$tmp" as the last line of the script.
rm -rf "$tmp"
trap 'rm -rf "$tmp"' EXIT right after creating it.
trap 'rm -rf "$tmp"' EXIT
Create it in /tmp, which is cleaned automatically after every script.
/tmp
trap 'rm -rf "$tmp"' SIGKILL