nicer names, update copyright
[errhandle.git] / README
1 Functions to deal with errors in bash
2
3 err: usually, just copy and source this. contains the other files
4
5
6 err-catch: set a trap on error to do bash-trace and exit
7 err-allow: undo errcatch
8 err-exit: exit and print stack trace
9 bash-trace: print stack trace (best bash stack trace ever)
10
11 the err* functions depend on bash-trace.
12
13 For scripts without any nested function calls, this is usually sufficient:
14 set -eE -o pipefail
15 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
16
17 Cleanup commands or functions can be appended to the ERR trap after a
18 semicolon within the single quotes.
19
20 Related: see my bash script template repo, at https://iankelling.org/git.
21
22 Please email me if you have a patches, bugs, feedback, or republish this
23 somewhere else: Ian Kelling <ian@iankelling.org>.