From f6080c0422e481370d9f584e2164e6cd3b644b8e Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Tue, 12 Feb 2013 18:35:31 +0000 Subject: [PATCH] Allow tweaking colour support from an environment variable. * Passing something like `BS_COLORS=0` disables colour support and is the same as passing `-N` to the script. --- bootstrap-salt.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index b77ee38..a83b246 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -18,10 +18,18 @@ set -o nounset # Treat unset variables as an error ScriptVersion="1.4" ScriptName="bootstrap-salt.sh" +#=============================================================================== +# Environment variables taken into account. +#------------------------------------------------------------------------------- +# * BS_COLORS: If 0 disables colour support +#=============================================================================== + + #=============================================================================== # LET THE BLACK MAGIC BEGIN!!!! #=============================================================================== + # Bootstrap script truth values BS_TRUE=1 BS_FALSE=0 @@ -30,7 +38,7 @@ BS_FALSE=0 # NAME: __detect_color_support # DESCRIPTION: Try to detect color support. #------------------------------------------------------------------------------- -COLORS=$(tput colors 2>/dev/null || echo 0) +COLORS=${BS_COLORS:-$(tput colors 2>/dev/null || echo 0)} __detect_color_support() { if [ $? -eq 0 ] && [ "$COLORS" -gt 2 ]; then RC="\033[1;31m"