# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
#
|
|
# Filename: lib/term-functions.in
|
|
# Copyright (C) 2006 - 2007 The OpenSDE Project
|
|
#
|
|
# More information can be found in the files COPYING and README.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; version 2 of the License. A copy of the
|
|
# GNU General Public License can be found in the file COPYING.
|
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
|
|
|
# COLOR_*
|
|
# FIXME: is the tty capable?
|
|
#
|
|
# '\E[COLOR1;COLOR2m'
|
|
#
|
|
# Color Fg Bg
|
|
# black 30 40
|
|
# red 31 41
|
|
# green 32 42
|
|
# yellow 33 43
|
|
# blue 34 44
|
|
# magenta 35 45
|
|
# cyan 36 46
|
|
# white 37 47
|
|
#
|
|
COLOR_NORMAL='\033[0m'
|
|
COLOR_INFO='\033[32;1m'
|
|
COLOR_TITLE='\033[35m'
|
|
COLOR_MESSAGE='\033[36m'
|
|
COLOR_SUCESS='\033[32m'
|
|
COLOR_WARNING='\033[33;1m'
|
|
COLOR_FAILURE='\033[31m'
|
|
|
|
# CLI fanciness
|
|
#
|
|
echo_msg() {
|
|
echo -e "${COLOR_MESSAGE}$*${COLOR_NORMAL}" >&2
|
|
}
|
|
|
|
echo_info() {
|
|
if [ ${verbose:-1} -ne 0 ]; then
|
|
if [ $# -gt 0 ]; then
|
|
echo -e "${COLOR_INFO}->${COLOR_NORMAL} $*" >&2
|
|
else
|
|
while read text; do
|
|
echo -e "${COLOR_INFO}->${COLOR_NORMAL} $text"
|
|
done >&2
|
|
fi
|
|
fi
|
|
}
|
|
|
|
echo_warning() {
|
|
echo -e "${COLOR_WARNING}*>${COLOR_NORMAL} $*" >&2
|
|
}
|
|
|
|
echo_error() {
|
|
echo -e "${COLOR_FAILURE}!> ERROR:${COLOR_NORMAL} $@" >&2
|
|
}
|
|
|
|
echo_abort() {
|
|
local errno="$1"; shift
|
|
echo_error "$@"
|
|
exit $errno
|
|
}
|