Skip to content

Commit 6aa4c1a

Browse files
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 <[email protected]> Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent b94b559 commit 6aa4c1a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

script/check-config.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env bash
22
set -e -u
33

4+
[ -t 1 ] || NO_COLOR=1
5+
46
# bits of this were adapted from check_config.sh in docker
57
# see also https://github.com/docker/docker/blob/master/contrib/check-config.sh
68

@@ -43,6 +45,8 @@ is_set_as_module() {
4345
}
4446

4547
color() {
48+
[ -n "${NO_COLOR:-}" ] && return
49+
4650
local codes=()
4751
if [ "$1" = 'bold' ]; then
4852
codes=("${codes[@]-}" '1')

0 commit comments

Comments
 (0)