From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 7754D15800F for ; Sun, 19 Feb 2023 16:14:36 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 69901E08C3; Sun, 19 Feb 2023 16:14:35 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 568DAE08C3 for ; Sun, 19 Feb 2023 16:14:35 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7FE90340ED3 for ; Sun, 19 Feb 2023 16:14:34 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2F2978B7 for ; Sun, 19 Feb 2023 16:14:32 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1676823246.c517951d98b6ae3c9ca0c838c029641287bd4d8d.sam@gentoo> Subject: [gentoo-commits] proj/gentoo-functions:master commit in: / X-VCS-Repository: proj/gentoo-functions X-VCS-Files: functions.sh X-VCS-Directories: / X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: c517951d98b6ae3c9ca0c838c029641287bd4d8d X-VCS-Branch: master Date: Sun, 19 Feb 2023 16:14:32 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 69c52c86-c71e-42a3-a987-171e9b48ff08 X-Archives-Hash: 44f1d50685469e437b34530539cc34fe commit: c517951d98b6ae3c9ca0c838c029641287bd4d8d Author: Kerin Millar plushkava net> AuthorDate: Sat Feb 18 06:55:02 2023 +0000 Commit: Sam James gentoo org> CommitDate: Sun Feb 19 16:14:06 2023 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=c517951d Support NO_COLOR as a means of suppressing coloured output Per https://no-color.org/, NO_COLOR is a de-facto standard for allowing the user to express their preference for not seeing coloured output. Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> functions.sh | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/functions.sh b/functions.sh index fbc0812..d068627 100644 --- a/functions.sh +++ b/functions.sh @@ -479,20 +479,23 @@ RC_GOT_FUNCTIONS="yes" EINFO_QUIET="${EINFO_QUIET:-no}" EINFO_VERBOSE="${EINFO_VERBOSE:-no}" -# Should we use color? -RC_NOCOLOR="${RC_NOCOLOR:-no}" - # Set the initial value for e-message indentation. genfun_indent= -for _ in "$@"; do - case $_ in - # Check whether the user specifed an argument to disable color. - --nocolor|--nocolour|-C) - RC_NOCOLOR="yes" - break - esac -done +# Should we use color? +if [ -n "${NO_COLOR}" ]; then + # See https://no-color.org/. + RC_NOCOLOR="yes" +else + RC_NOCOLOR="${RC_NOCOLOR:-no}" + for _ in "$@"; do + case $_ in + --nocolor|--nocolour|-C) + RC_NOCOLOR="yes" + break + esac + done +fi # Try to determine the number of available columns in the terminal. for _ in 1 2 3; do