blob: c936f633b4c53a77f65cbc87c796c849a0d390c9 (
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
46
47
48
49
50
51
52
53
54
|
# vim:ft=sh:noexpandtab
# Various echo functions
ECHO_VERBOSE=0
echo_info() {
set +x
[ $ECHO_VERBOSE -ge 0 ] || return
echo -e "\e[1;34m$@\e[0m" >&2
[ $ECHO_VERBOSE -lt 3 ] || set -x
}
echo_warn() {
set +x
[ $ECHO_VERBOSE -ge -1 ] || return
echo -e "\e[1;33m$@\e[0m" >&2
[ $ECHO_VERBOSE -lt 3 ] || set -x
}
echo_error() {
set +x
[ $ECHO_VERBOSE -ge -2 ] || return
echo -e "\e[1;31m$@\e[0m" >&2
[ $ECHO_VERBOSE -lt 3 ] || set -x
}
echo_die() {
set +x
if [ $ECHO_VERBOSE -ge -2 ]; then
echo -e "\e[1;31m$@\e[0m" >&2
fi
[ $ECHO_VERBOSE -lt 3 ] || set -x
# Suicide
kill $$
}
echo_dbg() {
set +x
[ $ECHO_VERBOSE -ge 1 ] || return
echo -e "\e[1;90m$@\e[0m" >&2
[ $ECHO_VERBOSE -lt 3 ] || set -x
}
echo_trace() {
set +x
[ $ECHO_VERBOSE -ge 2 ] || return
echo -e "\e[1;90m$@\e[0m" >&2
[ $ECHO_VERBOSE -lt 3 ] || set -x
}
echo_verbose() {
ECHO_VERBOSE=$(expr $ECHO_VERBOSE $1 $2)
[ $ECHO_VERBOSE -ge 3 ] && set -x || set +x
}
|