blob: 69ec0be095eb26a596b3303f2d0cc0848a8b7df8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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.
|