From 6aa4c1a13ee173b689654b528cf3c83820ceb1d5 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 19 Dec 2023 17:26:35 -0800 Subject: [PATCH] script/check-config: disable colors ...when the stdout is not a terminal, and also when NO_COLOR environment variable is set to any non-empty value (as per no-color.org). Co-authored-by: Akihiro Suda Signed-off-by: Kir Kolyshkin --- script/check-config.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/script/check-config.sh b/script/check-config.sh index 2de94d292..9c26152ea 100755 --- a/script/check-config.sh +++ b/script/check-config.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -e -u +[ -t 1 ] || NO_COLOR=1 + # bits of this were adapted from check_config.sh in docker # see also https://github.com/docker/docker/blob/master/contrib/check-config.sh @@ -43,6 +45,8 @@ is_set_as_module() { } color() { + [ -n "${NO_COLOR:-}" ] && return + local codes=() if [ "$1" = 'bold' ]; then codes=("${codes[@]-}" '1')