From: Thomas Haller <thaller@redhat.com>
To: NetFilter <netfilter-devel@vger.kernel.org>
Cc: Thomas Haller <thaller@redhat.com>
Subject: [PATCH nft 1/1] tests/shell: honor CLICOLOR_FORCE to force coloring in run-tests.sh
Date: Thu, 14 Sep 2023 15:16:07 +0200 [thread overview]
Message-ID: <20230914131723.4134745-1-thaller@redhat.com> (raw)
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
reply other threads:[~2023-09-14 13:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230914131723.4134745-1-thaller@redhat.com \
--to=thaller@redhat.com \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).