Functions to deal with errors in bash
-bash-trace: print stack trace (best bash stack trace ever).
-errcatch: on error, do stack trace ane exit
+errcatch: set a trap on error to do bash-trace and exit
errallow: undo errcatch
errexit: exit and print stack trace
+bash-trace: print stack trace (best bash stack trace ever)
the err* functions depend on bash-trace.
# See the License for the specific language governing permissions and
# limitations under the License.
-shopt -s extdebug
+# Note: bash-trace will not show function args unless you first run:
+# shopt -s extdebug
+# Also note, setting extdebug in your .bashrc causes spam in bash 4.4.
+
bash-trace() {
- # shows function args when: shopt -s extdebug
local -i argc_index=0 arg frame i start=${1:-1} max_indent=8 indent
local source
local extdebug=false