dev-python/conda-libmamba-solver: bump version to 24.11.1
[gentoo-zh.git] / sys-libs / elog-functions / files / elog-functions.sh
blob793da5b2667ee46ec26502f49643b7a16262ed10
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
5 for arg; do
6 case "$arg" in
7 --nocolor|--nocolour|-C)
8 export EINFO_COLOR="NO"
9 ;;
10 esac
11 done
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
26 function elog()
28 if [ "${EINFO_QUIET}" == "true" ]; then
29 return
31 echo -ne "${@}"
34 function errlog()
36 echo -ne "${@}" > /dev/stderr
39 function einfo()
41 elog " ${GOOD}*${NORMAL} ${_ELOG_INDENT}${@}\n"
44 function ewarn()
46 errlog " ${WARN}*${NORMAL} ${_ELOG_INDENT}${@}\n"
49 function eerror()
51 errlog " ${BAD}*${NORMAL} ${_ELOG_INDENT}${@}\n"
54 function veinfo()
56 if [ "${EINFO_VERBOSE}" == "true" ]; then
57 einfo "${@}"
61 function vewarn()
63 if [ "${EINFO_VERBOSE}" ]; then
64 ewarn "${@}"
68 function ebegin()
70 elog " ${GOOD}*${NORMAL} ${_ELOG_INDENT}${@} ...\n"
73 function eend()
75 if [ "${EINFO_QUIET}" == "true" ]; then
76 return
78 msg="$1"
79 if [ ! -z "${msg##*[!0-9]*}" ]; then
80 retval="$msg"
81 else
82 eerror "$msg"
83 retval=1
85 # go up
86 echo -ne "\e[1A"
87 # ncurses dependency
88 COLUMNS=$(/usr/bin/tput cols)
89 COLUMN=$((COLUMNS - 6))
90 # goto column
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}"
96 else
97 echo -e "${LBRAC} ${BAD}!!${NORMAL} ${RBRAC}"
101 function eindent()
103 if [ -z "${_ELOG_INDENT}" ]; then
104 export _ELOG_INDENT=" "
105 else
106 export _ELOG_INDENT="${_ELOG_INDENT} "
110 function eoutdent()
112 if [ -z "${_ELOG_INDENT}" ]; then
113 unset _ELOG_INDENT
114 else
115 export _ELOG_INDENT=$(echo "${_ELOG_INDENT}" | sed "s/ //")
119 export -f elog errlog einfo ewarn eerror veinfo vewarn ebegin eend eindent eoutdent