summaryrefslogtreecommitdiffstats
path: root/packaging/macos/jhb/usr/src/bash_d/error.sh
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/macos/jhb/usr/src/bash_d/error.sh')
-rw-r--r--packaging/macos/jhb/usr/src/bash_d/error.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/packaging/macos/jhb/usr/src/bash_d/error.sh b/packaging/macos/jhb/usr/src/bash_d/error.sh
new file mode 100644
index 0000000..69ec0be
--- /dev/null
+++ b/packaging/macos/jhb/usr/src/bash_d/error.sh
@@ -0,0 +1,45 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# https://github.com/dehesselle/bash_d
+
+### includes ###################################################################
+
+bash_d_include ansi.sh
+bash_d_include echo.sh
+
+### variables ##################################################################
+
+# Nothing here.
+
+### functions ##################################################################
+
+function error_catch
+{
+ local rc=$1
+
+ local index=0
+ local output
+
+ while output=$(caller $index); do
+ if [ $index -eq 0 ]; then
+ if ansi_is_usable; then
+ echo_e "rc=$rc $ANSI_FG_YELLOW_BRIGHT$BASH_COMMAND$ANSI_FG_RESET"
+ else
+ echo "rc=$rc $BASH_COMMAND"
+ fi
+ fi
+
+ echo_e $output
+ ((index+=1))
+ done
+
+ exit $rc
+}
+
+### aliases ####################################################################
+
+alias error_trace_enable='set -o errtrace; trap '\''error_catch ${?}'\'' ERR'
+alias error_trace_disable='trap - ERR'
+
+### main #######################################################################
+
+# Nothing here. \ No newline at end of file