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