Enable colour only when writing to a tty

The escape codes can confuse other scripts and things in pipes
This commit is contained in:
Andrew Stevenson
2022-07-23 09:29:42 +00:00
parent 639334052f
commit a0b7bc54e0

View File

@@ -38,7 +38,7 @@ enable_color() {
}
# If "NO_COLOR" environment variable is present, disable output colors.
if [ -z "${NO_COLOR}" ]; then
if [ -z "${NO_COLOR}" -a -t 1 ]; then
enable_color
fi