* [PATCH nft 1/1] tests/shell: honor CLICOLOR_FORCE to force coloring in run-tests.sh
@ 2023-09-14 13:16 Thomas Haller
0 siblings, 0 replies; only message in thread
From: Thomas Haller @ 2023-09-14 13:16 UTC (permalink / raw)
To: NetFilter; +Cc: Thomas Haller
We honor NO_COLOR= to disable coloring, let's also honor CLICOLOR_FORCE=
to enable it.
The purpose will be for `make` calling the script and redirecting to a
file, while enabling colors.
See-also: https://bixense.com/clicolors/
Signed-off-by: Thomas Haller <thaller@redhat.com>
---
tests/shell/run-tests.sh | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/tests/shell/run-tests.sh b/tests/shell/run-tests.sh
index f75505f7f1b4..bf5fc382ac04 100755
--- a/tests/shell/run-tests.sh
+++ b/tests/shell/run-tests.sh
@@ -4,11 +4,16 @@ GREEN=""
YELLOW=""
RED=""
RESET=""
-if [[ -t 1 && -z "$NO_COLOR" ]] ; then
- GREEN=$'\e[32m'
- YELLOW=$'\e[33m'
- RED=$'\e[31m'
- RESET=$'\e[0m'
+if [ -z "$NO_COLOR" ] ; then
+ if [ -n "$CLICOLOR_FORCE" ] || [[ -t 1 ]] ; then
+ # See https://bixense.com/clicolors/ . We only check isatty() on
+ # file descriptor 1, to decide whether colorizing happens (although,
+ # we might also colorize on other places/FDs).
+ GREEN=$'\e[32m'
+ YELLOW=$'\e[33m'
+ RED=$'\e[31m'
+ RESET=$'\e[0m'
+ fi
fi
array_contains() {
--
2.41.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-09-14 13:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-14 13:16 [PATCH nft 1/1] tests/shell: honor CLICOLOR_FORCE to force coloring in run-tests.sh Thomas Haller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).