From 45165467fa1a3d1d11d683d66d529fd787a146a5 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 29 Jun 2026 17:41:19 +0100 Subject: Respect NO_COLOR and FORCE_COLOR in configure. --- make/console.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/make/console.pm b/make/console.pm index 37a5fd09d..be257ca18 100644 --- a/make/console.pm +++ b/make/console.pm @@ -56,11 +56,22 @@ struct 'command' => { 'description' => '$', }; +sub _use_color() { + if ($ENV{FORCE_COLOR}) { + return 1; + } elsif ($ENV{NO_COLOR}) { + return 0; + } elsif ($ENV{GITHUB_ACTIONS}) { + return 1; + } + return -t STDOUT; +} + sub console_format($) { my $message = shift; while ($message =~ /(<\|(\S+)\s(.*?)\|>)/) { my ($match, $type, $text) = ($1, uc $2, $3); - if (-t STDOUT && exists $FORMAT_CODES{$type}) { + if (_use_color() && exists $FORMAT_CODES{$type}) { $message =~ s/\Q$match\E/$FORMAT_CODES{$type}$text$FORMAT_CODES{DEFAULT}/; } else { $message =~ s/\Q$match\E/$text/; -- cgit v1.3.1-10-gc9f91