summaryrefslogtreecommitdiffstats
path: root/packaging/macos/jhb/usr/src/bash_d/error.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
commitcca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch)
tree146f39ded1c938019e1ed42d30923c2ac9e86789 /packaging/macos/jhb/usr/src/bash_d/error.sh
parentInitial commit. (diff)
downloadinkscape-12fc8abae6d434cac7670a59ed3a67301cc2eb10.tar.xz
inkscape-12fc8abae6d434cac7670a59ed3a67301cc2eb10.zip
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-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