From d662682fb567cebb5efa466f2d62f7574ce3dac8 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Fri, 24 Sep 2021 20:37:55 +0200 Subject: [PATCH] Honour NO_COLOR in bootstrap scrips, fixes #248 --- scripts/bootstrap/bootstrap-haskell | 66 ++++++++++++++++++----------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/scripts/bootstrap/bootstrap-haskell b/scripts/bootstrap/bootstrap-haskell index 0b1c54e..12a6594 100755 --- a/scripts/bootstrap/bootstrap-haskell +++ b/scripts/bootstrap/bootstrap-haskell @@ -52,41 +52,57 @@ esac die() { - (>&2 printf "\\033[0;31m%s\\033[0m\\n" "$1") + if [ -n "${NO_COLOR}" ] ; then + (>&2 printf "%s\\n" "$1") + else + (>&2 printf "\\033[0;31m%s\\033[0m\\n" "$1") + fi exit 2 } warn() { - case "${plat}" in - MSYS*|MINGW*) - echo -e "\\033[0;35m$1\\033[0m" - ;; - *) - printf "\\033[0;35m%s\\033[0m\\n" "$1" - ;; - esac + if [ -n "${NO_COLOR}" ] ; then + printf "%s\\n" "$1" + else + case "${plat}" in + MSYS*|MINGW*) + echo -e "\\033[0;35m$1\\033[0m" + ;; + *) + printf "\\033[0;35m%s\\033[0m\\n" "$1" + ;; + esac + fi } yellow() { - case "${plat}" in - MSYS*|MINGW*) - echo -e "\\033[0;33m$1\\033[0m" - ;; - *) - printf "\\033[0;33m%s\\033[0m\\n" "$1" - ;; - esac + if [ -n "${NO_COLOR}" ] ; then + printf "%s\\n" "$1" + else + case "${plat}" in + MSYS*|MINGW*) + echo -e "\\033[0;33m$1\\033[0m" + ;; + *) + printf "\\033[0;33m%s\\033[0m\\n" "$1" + ;; + esac + fi } green() { - case "${plat}" in - MSYS*|MINGW*) - echo -e "\\033[0;32m$1\\033[0m" - ;; - *) - printf "\\033[0;32m%s\\033[0m\\n" "$1" - ;; - esac + if [ -n "${NO_COLOR}" ] ; then + printf "%s\\n" "$1" + else + case "${plat}" in + MSYS*|MINGW*) + echo -e "\\033[0;32m$1\\033[0m" + ;; + *) + printf "\\033[0;32m%s\\033[0m\\n" "$1" + ;; + esac + fi } edo() {