78873d6d4f7f40b70f463512aff4fb6ec215f5f5
[errhandle.git] / README
1 Functions to deal with errors in bash
2
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)
7
8 the err* functions depend on bash-trace.
9
10 For scripts without any nested function calls, this is usually sufficient:
11 set -eE -o pipefail
12 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
13
14 Cleanup commands or functions can be appended to the ERR trap after a
15 semicolon within the single quotes.
16
17 Related: see my bash script template repo, at https://iankelling.org/git.
18
19 Please email me if you have a patches, bugs, feedback, or republish this
20 somewhere else: Ian Kelling <ian@iankelling.org>.