1 Functions to deal with errors in bash
3 errcatch: set a trap on error to do bash-trace and exit
4 errallow: undo errcatch
5 errexit: exit and print stack trace
6 bash-trace: print stack trace (best bash stack trace ever)
8 the err* functions depend on bash-trace.
10 For scripts without any nested function calls, this is usually sufficient:
12 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
14 Cleanup commands or functions can be appended to the ERR trap after a
15 semicolon within the single quotes.
17 Related: see my bash script template repo, at https://iankelling.org/git.
19 Please email me if you have a patches, bugs, feedback, or republish this
20 somewhere else: Ian Kelling <ian@iankelling.org>.