add err-print, slight output improvement, docs
[errhandle.git] / README
diff --git a/README b/README
index 8bbec69b987e37ab2163d092e5b0eba9e8e95d9f..b8e85f293991ede0c82367c9c54a2b36a4a0c9d9 100644 (file)
--- a/README
+++ b/README
@@ -1,17 +1,22 @@
-The main usage documentation is near the top of any bash script files which sit
-next to this file.
+Bash stack trace and error handling functions
 
-Files ending in -function are for sourcing then calling as a function. Files
-without -function are exactly the same except they are for calling as a script.
+Usually, just copy the err file and source it. Then on any non-zero
+return code outside of a conditional, the program will exit and print a
+stack trace.
 
-Patches and bugs are very welcome via gitlab.
+The err file has some functions which you may want to call manually for
+different or additional error handling. See the comments at the start of
+each one.
 
-Questions, feedback, etc are very welcome via email to Ian Kelling
-<ian@iankelling.org>. I will add any useful questions, answers, etc. to this
-file. The scope/userbase of this project doesn't justify a mailing list, but if
-it ever did I would start a discourse instance category to act as a mailing list
-and forum.
+For scripts where functions are not used, you can optionally use a more
+minimal approach:
+set -eE -o pipefail
+trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 
-This program is also part of a collection of programs,
-https://gitlab.com/iankelling/bash-programs-by-ian, which are unrelated except
-having the same author and being being bash programs.
+In the above line, cleanup commands or functions can be appended to the
+ERR trap after a semicolon within the single quotes.
+
+Related: see my bash script template repo, at https://iankelling.org/git.
+
+Please email me if you have a patches, bugs, feedback, or republish this
+somewhere else: Ian Kelling <ian@iankelling.org>.