From d97b2b3793771a959dc92d66251cdca5b1b4e252 Mon Sep 17 00:00:00 2001 From: MilhouseVH Date: Wed, 21 Nov 2018 11:43:03 +0000 Subject: [PATCH] config/functions: fix colors - escape sequences are not supported --- config/functions | 73 +++++++++++++++++++++++++++++------------------- config/path | 21 -------------- 2 files changed, 45 insertions(+), 49 deletions(-) diff --git a/config/functions b/config/functions index e4662e687a..c3954501a1 100644 --- a/config/functions +++ b/config/functions @@ -37,6 +37,8 @@ listremoveitem() { print_color() { local clr_name="$1" clr_text="$2" clr_actual + local black red green yellow blue magenta cyan white endcolor + local boldblack boldred boldgreen boldyellow boldblue boldmagenta boldcyan boldwhite [ -z "${clr_name}" ] && return 0 @@ -45,45 +47,60 @@ print_color() { return 0 fi + black="\e[0;30m" + boldblack="\e[1;30m" + red="\e[0;31m" + boldred="\e[1;31m" + green="\e[0;32m" + boldgreen="\e[1;32m" + yellow="\e[0;33m" + boldyellow="\e[1;33m" + blue="\e[0;34m" + boldblue="\e[1;34m" + magenta="\e[0;35m" + boldmagenta="\e[1;35m" + cyan="\e[0;36m" + boldcyan="\e[1;36m" + white="\e[0;37m" + boldwhite="\e[1;37m" + endcolor="\e[0m" + + # $clr_name can be a color variable (boldgreen etc.) or a + # "standard" color determined by an indirect name (CLR_ERROR etc.) + # + # If ${!clr_name} doesn't exist then assume it's a standard color. + # clr_actual="${!clr_name}" - # If $clr_name isn't another colour variable (boldgreen etc.), then - # assume it's an actual colour escape sequence. - # - # Otherwise if $clr_name isn't defined, or doesn't exist, then use - # standard colours. - # - if [[ -n "${clr_actual}" ]] && [[ -z "${!clr_actual}" ]]; then - clr_actual="${clr_name}" - elif [[ -z "${clr_actual}" ]] || [[ -z "${!clr_actual}" ]]; then + if [ -z "${clr_actual}" ]; then case "${clr_name}" in - CLR_ERROR) clr_actual="boldred";; - CLR_WARNING) clr_actual="boldred";; - CLR_WARNING_DIM) clr_actual="red";; + CLR_ERROR) clr_actual="${boldred}";; + CLR_WARNING) clr_actual="${boldred}";; + CLR_WARNING_DIM) clr_actual="${red}";; - CLR_APPLY_PATCH) clr_actual="boldgreen";; - CLR_AUTORECONF) clr_actual="boldmagenta";; - CLR_BUILD) clr_actual="boldyellow";; - CLR_TOOLCHAIN) clr_actual="boldmagenta";; - CLR_CLEAN) clr_actual="boldred";; - CLR_FIXCONFIG) clr_actual="boldyellow";; - CLR_GET) clr_actual="boldcyan";; - CLR_INFO) clr_actual="boldgreen";; - CLR_INSTALL) clr_actual="boldgreen";; - CLR_PATCH_DESC) clr_actual="boldwhite";; - CLR_TARGET) clr_actual="boldwhite";; - CLR_UNPACK) clr_actual="boldcyan";; + CLR_APPLY_PATCH) clr_actual="${boldgreen}";; + CLR_AUTORECONF) clr_actual="${boldmagenta}";; + CLR_BUILD) clr_actual="${boldyellow}";; + CLR_TOOLCHAIN) clr_actual="${boldmagenta}";; + CLR_CLEAN) clr_actual="${boldred}";; + CLR_FIXCONFIG) clr_actual="${boldyellow}";; + CLR_GET) clr_actual="${boldcyan}";; + CLR_INFO) clr_actual="${boldgreen}";; + CLR_INSTALL) clr_actual="${boldgreen}";; + CLR_PATCH_DESC) clr_actual="${boldwhite}";; + CLR_TARGET) clr_actual="${boldwhite}";; + CLR_UNPACK) clr_actual="${boldcyan}";; - CLR_ENDCOLOR) clr_actual="endcolor";; + CLR_ENDCOLOR) clr_actual="${endcolor}";; - *) clr_actual="endcolor";; + *) clr_actual="${endcolor}";; esac fi if [ $# -eq 2 ]; then - echo -en "${!clr_actual}${clr_text}${endcolor}" + echo -en "${clr_actual}${clr_text}${endcolor}" else - echo -en "${!clr_actual}" + echo -en "${clr_actual}" fi } diff --git a/config/path b/config/path index 77d3bd7f62..3f540890a7 100644 --- a/config/path +++ b/config/path @@ -162,27 +162,6 @@ else fi BUILD_INDENT_SIZE=4 -# define colors -if [ "$DISABLE_COLORS" != "yes" ]; then - black="\e[0;30m" - boldblack="\e[1;30m" - red="\e[0;31m" - boldred="\e[1;31m" - green="\e[0;32m" - boldgreen="\e[1;32m" - yellow="\e[0;33m" - boldyellow="\e[1;33m" - blue="\e[0;34m" - boldblue="\e[1;34m" - magenta="\e[0;35m" - boldmagenta="\e[1;35m" - cyan="\e[0;36m" - boldcyan="\e[1;36m" - white="\e[0;37m" - boldwhite="\e[1;37m" - endcolor="\e[0m" -fi - # If sourcing a package, configure any package variables dependent on variables we have set if [ -n "$PKG_DIR" -a -r $PKG_DIR/package.mk ]; then if [ "$(type -t configure_package)" = "function" ]; then