Error handling in Bash

Use a trap! …then, whenever you create a temporary file: and $temp_foo will be deleted on exit, and the current line number will be printed. (set -e will likewise give you exit-on-error behavior, though it comes with serious caveats and weakens code’s predictability and portability). You can either let the trap call error for you (in which case it uses the default … Read more