add NO_COLOR support
This commit is contained in:
@@ -124,25 +124,45 @@ export On_IWhite='\e[0;107m'
|
|||||||
# D : debug (cyan)
|
# D : debug (cyan)
|
||||||
disp()
|
disp()
|
||||||
{
|
{
|
||||||
|
# Handle NO_COLOR: disable colors if set
|
||||||
|
local color_enabled=1
|
||||||
|
[[ -n $NO_COLOR ]] && color_enabled=0
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
"I")
|
"I")
|
||||||
|
if [[ $color_enabled -eq 1 ]]; then
|
||||||
local heads="[ ${IGreen}info${DEFAULTFG} ]"
|
local heads="[ ${IGreen}info${DEFAULTFG} ]"
|
||||||
|
else
|
||||||
|
local heads="[ info ]"
|
||||||
|
fi
|
||||||
shift
|
shift
|
||||||
[[ -z $QUIET || $QUIET -ne 1 ]] && \
|
[[ -z $QUIET || $QUIET -ne 1 ]] && \
|
||||||
printf "%b\n" "${heads} $*${RESETCOL}"
|
printf "%b\n" "${heads} $*${RESETCOL}"
|
||||||
;;
|
;;
|
||||||
"W")
|
"W")
|
||||||
|
if [[ $color_enabled -eq 1 ]]; then
|
||||||
local heads="[ ${IYellow}Warning${DEFAULTFG} ]"
|
local heads="[ ${IYellow}Warning${DEFAULTFG} ]"
|
||||||
|
else
|
||||||
|
local heads="[ Warning ]"
|
||||||
|
fi
|
||||||
shift
|
shift
|
||||||
printf "%b\n" "${heads} $*${RESETCOL}" >&2
|
printf "%b\n" "${heads} $*${RESETCOL}" >&2
|
||||||
;;
|
;;
|
||||||
"E")
|
"E")
|
||||||
|
if [[ $color_enabled -eq 1 ]]; then
|
||||||
local heads="[ ${IRed}ERROR${DEFAULTFG} ]"
|
local heads="[ ${IRed}ERROR${DEFAULTFG} ]"
|
||||||
|
else
|
||||||
|
local heads="[ ERROR ]"
|
||||||
|
fi
|
||||||
shift
|
shift
|
||||||
printf "%b\n" "${heads} $*${RESETCOL}" >&2
|
printf "%b\n" "${heads} $*${RESETCOL}" >&2
|
||||||
;;
|
;;
|
||||||
"D")
|
"D")
|
||||||
|
if [[ $color_enabled -eq 1 ]]; then
|
||||||
local heads="[ ${ICyan}debug${DEFAULTFG} ]"
|
local heads="[ ${ICyan}debug${DEFAULTFG} ]"
|
||||||
|
else
|
||||||
|
local heads="[ debug ]"
|
||||||
|
fi
|
||||||
shift
|
shift
|
||||||
[[ -n $DEBUG && $DEBUG -gt 1 ]] && \
|
[[ -n $DEBUG && $DEBUG -gt 1 ]] && \
|
||||||
printf "%b\n" "${heads} $*${RESETCOL}"
|
printf "%b\n" "${heads} $*${RESETCOL}"
|
||||||
@@ -157,4 +177,7 @@ export -f disp
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
# Load disp section variables
|
||||||
|
load_conf disp
|
||||||
|
|
||||||
# EOF
|
# EOF
|
||||||
|
|||||||
Reference in New Issue
Block a user