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.
This commit is contained in:
Pedro Algarvio 2013-02-12 18:35:31 +00:00
parent 7792f4c8c0
commit f6080c0422

View file

@ -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"