diff options
| author | 2026-06-29 17:41:19 +0100 | |
|---|---|---|
| committer | 2026-06-29 17:41:19 +0100 | |
| commit | 45165467fa1a3d1d11d683d66d529fd787a146a5 (patch) | |
| tree | d5e5de10d86d02f99e799e6fb47b63b0632f499c | |
| parent | Fix null bytes not being encoded correctly by Percent::Encode. (diff) | |
Respect NO_COLOR and FORCE_COLOR in configure.
| -rw-r--r-- | make/console.pm | 13 |
1 files changed, 12 insertions, 1 deletions
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/; |
