1 # Copyright (c) 2012 Canek Peláez Valdés <canek@ciencias.unam.mx>
2 # Compatibility e* log functions from sys-apps/openrc
4 # Shamelessly stolen from /etc/init.d/functions.sh
7 --nocolor|
--nocolour|
-C)
8 export EINFO_COLOR
="NO"
13 # Adapted from /etc/init.d/functions.sh so we don't need eval_colors
14 if [ "${EINFO_COLOR}" != NO
]; then
15 if [ -z "$GOOD" ]; then
16 GOOD
=$
(echo -ne "\e[1;32m")
17 WARN
=$
(echo -ne "\e[1;33m")
18 BAD
=$
(echo -ne "\e[1;31m")
19 HILITE
=$
(echo -ne "\e[1;36m")
20 BRACKET
=$
(echo -ne "\e[1;34m")
21 NORMAL
=$
(echo -ne "\e[0;0m")
22 export GOOD WARN BAD HILITE BRACKET NORMAL
28 if [ "${EINFO_QUIET}" == "true" ]; then
36 echo -ne "${@}" > /dev
/stderr
41 elog
" ${GOOD}*${NORMAL} ${_ELOG_INDENT}${@}\n"
46 errlog
" ${WARN}*${NORMAL} ${_ELOG_INDENT}${@}\n"
51 errlog
" ${BAD}*${NORMAL} ${_ELOG_INDENT}${@}\n"
56 if [ "${EINFO_VERBOSE}" == "true" ]; then
63 if [ "${EINFO_VERBOSE}" ]; then
70 elog
" ${GOOD}*${NORMAL} ${_ELOG_INDENT}${@} ...\n"
75 if [ "${EINFO_QUIET}" == "true" ]; then
79 if [ ! -z "${msg##*[!0-9]*}" ]; then
88 COLUMNS
=$
(/usr
/bin
/tput cols
)
89 COLUMN
=$
((COLUMNS
- 6))
91 echo -ne "\e[${COLUMN}C"
92 LBRAC
="${BRACKET}[${NORMAL}"
93 RBRAC
="${BRACKET}]${NORMAL}"
94 if [ "$retval" != 1 ]; then
95 echo -e "${LBRAC} ${GOOD}ok${NORMAL} ${RBRAC}"
97 echo -e "${LBRAC} ${BAD}!!${NORMAL} ${RBRAC}"
103 if [ -z "${_ELOG_INDENT}" ]; then
104 export _ELOG_INDENT
=" "
106 export _ELOG_INDENT
="${_ELOG_INDENT} "
112 if [ -z "${_ELOG_INDENT}" ]; then
115 export _ELOG_INDENT
=$
(echo "${_ELOG_INDENT}" |
sed "s/ //")
119 export -f elog errlog einfo ewarn eerror veinfo vewarn ebegin eend eindent eoutdent