fix regression in last commit, ommiting a frame
[errhandle.git] / README
1 Bash stack trace and error handling functions
2
3 Usually, just copy the err file and source it. Then on any non-zero
4 return code outside of a conditional, the program will exit and print a
5 stack trace.
6
7 The err file has some functions which you may want to call manually for
8 different or additional error handling. See the comments at the start of
9 each one.
10
11 For scripts where functions are not used, you can optionally use a more
12 minimal approach:
13 set -eE -o pipefail
14 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
15
16 In the above line, cleanup commands or functions can be appended to the
17 ERR trap after a semicolon within the single quotes.
18
19 Related: see my bash script template repo, at https://iankelling.org/git.
20
21 Please email me if you have a patches, bugs, feedback, or republish this
22 somewhere else: Ian Kelling <ian@iankelling.org>.