From f0f80e292439c86380d5a830f9db6c0d4d1cc6ae Mon Sep 17 00:00:00 2001 From: Geoffray Levasseur-Brandin Date: Thu, 19 Jun 2025 14:47:14 +0200 Subject: [PATCH] better display implementation --- profile.d/disp.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/profile.d/disp.sh b/profile.d/disp.sh index d517c39..70b7124 100644 --- a/profile.d/disp.sh +++ b/profile.d/disp.sh @@ -41,6 +41,7 @@ export DEFAULTFG="\e[0;39m" export DEFAULTBG="\e[0;49m" export DEFAULTCOL=${DEFAULTBG}${DEFAULTFG} +export RESETCOL=$'\e[0m' # Regular Colors export Black='\e[0;30m' @@ -121,31 +122,31 @@ disp() "I") local heads="[ ${IGreen}info${DEFAULTFG} ]" shift - [[ -z $QUIET || $QUIET -ne 1 ]] && echo -e "${heads} $@" + [[ -z $QUIET || $QUIET -ne 1 ]] && \ + printf "%b\n" "${heads} $*${RESETCOL}" ;; "W") local heads="[ ${IYellow}Warning${DEFAULTFG} ]" shift - echo -e "${heads} $@" >&2 + printf "%b\n" "${heads} $*${RESETCOL}" >&2 ;; "E") local heads="[ ${IRed}ERROR${DEFAULTFG} ]" shift - echo -e "${heads} $@" >&2 + printf "%b\n" "${heads} $*${RESETCOL}" >&2 ;; "D") - local heads"[ ${ICyan}debug${DEFAULTFG} ]" + local heads="[ ${ICyan}debug${DEFAULTFG} ]" shift - [[ -n $DEBUG && $DEBUG -gt 1 ]] && echo -e "${heads} $@" + [[ -n $DEBUG && $DEBUG -gt 1 ]] && \ + printf "%b\n" "${heads} $*${RESETCOL}" ;; - "*") - local heads="" - [[ -z $QUIET || $QUIET -ne 1 ]] && echo -e "$@" + * ) + [[ -z $QUIET || $QUIET -ne 1 ]] && \ + printf "%b\n" "$*" ;; esac - unset heads } export -f disp - # ------------------------------------------------------------------------------ # EOF