commit:     2ba6c4f1f86ff15cf11fdb515a22989a3d16f5ab
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Thu May 16 12:32:50 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri May 17 01:40:20 2024 +0000
URL:        
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=2ba6c4f1

Rename _has_monochrome_terminal() to _has_color_terminal()

This also inverts the sense of its exit status but it feels a little
more natural this way. Moreover, the behaviour now matches the
description of the function.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>

 functions.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/functions.sh b/functions.sh
index e2af8cf..e494765 100644
--- a/functions.sh
+++ b/functions.sh
@@ -444,18 +444,18 @@ _has_dumb_terminal()
 #
 # Tries to determine whether the terminal supports ECMA-48 SGR color sequences.
 #
-_has_monochrome_terminal()
+_has_color_terminal()
 {
        local colors
 
        # The tput(1) invocation is not portable, though ncurses suffices. In
        # this day and age, it is exceedingly unlikely that it will be needed.
        if _has_dumb_terminal; then
-               true
+               false
        elif colors=$(tput colors 2>/dev/null) && is_int "${colors}"; then
-               test "${colors}" -eq -1
+               test "${colors}" -gt 0
        else
-               false
+               true
        fi
 }
 
@@ -545,7 +545,7 @@ else
        done
 fi
 
-if _has_monochrome_terminal || yesno "${RC_NOCOLOR}"; then
+if ! _has_color_terminal || yesno "${RC_NOCOLOR}"; then
        unset -v BAD BRACKET GOOD HILITE NORMAL WARN
 else
        # Define some ECMA-48 SGR sequences for color support. These variables

Reply via email to