Skip to content

fix(ui): honour CLICOLOR and CLICOLOR_FORCE - #783

Merged
indaco merged 1 commit into
mainfrom
fix/clicolor-policy-resolver
Jul 26, 2026
Merged

fix(ui): honour CLICOLOR and CLICOLOR_FORCE#783
indaco merged 1 commit into
mainfrom
fix/clicolor-policy-resolver

Conversation

@indaco

@indaco indaco commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Description

malt honoured NO_COLOR and nothing else, so there was no way to ask for colour - the knob you need when piping into less -R or when a CI job wants ANSI in its log. CLICOLOR_FORCE now emits colour even when stderr is not a terminal, and CLICOLOR=0 turns it off. NO_COLOR stays an unconditional veto, matching how mt tui has always treated it.

The decision is now a named, pure precedence table instead of one fused env-read-and-TTY-probe expression, so the ordering is a tested contract rather than an accident of how a line was written. Colour is a tri-state (auto/always/never) because "colour regardless of TTY" is not something a TTY probe can express.

With none of the three variables set, behaviour is unchanged.

Related Issue

  • None

Notes for Reviewers

  • Precedence is deliberate: NO_COLOR beats CLICOLOR_FORCE, pinned by a named test.
  • NO_COLOR disables on presence alone, so NO_COLOR= and NO_COLOR=0 also disable. That diverges from no-color.org and is kept so existing behaviour cannot regress - flagged in a comment and pinned by a test, not changed here.

This is part 1 of 3 in a stack made with GitButler:

CLICOLOR_FORCE now emits colour even when stderr is not a terminal - the knob
needed when piping into less -R or asking a CI job for ANSI - and CLICOLOR=0
turns colour off. NO_COLOR stays an unconditional veto that nothing overrides.

The decision is now a named, pure precedence table instead of a fused
env-read-and-TTY-probe expression, so every combination is directly testable and
the ordering is a documented contract.
@indaco
indaco merged commit bf131a7 into main Jul 26, 2026
3 checks passed
@indaco
indaco deleted the fix/clicolor-policy-resolver branch July 26, 2026 20:59
indaco added a commit that referenced this pull request Jul 27, 2026
CLICOLOR_FORCE now emits colour even when stderr is not a terminal - the knob
needed when piping into less -R or asking a CI job for ANSI - and CLICOLOR=0
turns colour off. NO_COLOR stays an unconditional veto that nothing overrides.

The decision is now a named, pure precedence table instead of a fused
env-read-and-TTY-probe expression, so every combination is directly testable and
the ordering is a documented contract.

(cherry picked from commit bf131a7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant