aboutsummaryrefslogtreecommitdiff
path: root/utils/echo
diff options
context:
space:
mode:
Diffstat (limited to 'utils/echo')
-rw-r--r--utils/echo54
1 files changed, 54 insertions, 0 deletions
diff --git a/utils/echo b/utils/echo
new file mode 100644
index 0000000..c936f63
--- /dev/null
+++ b/utils/echo
@@ -0,0 +1,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
+}