Skip to content

diff: color --color=auto output when TERM is unset - #372

Merged
sylvestre merged 1 commit into
uutils:mainfrom
sarankumar1325:fix/color-auto-unset-term
Nov 10, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
sarankumar1325:fix/color-auto-unset-term

Conversation

@sarankumar1325

Copy link
Copy Markdown
Contributor

Fixes #352

With --color=auto, GNU diff colors the output on a terminal unless TERM=dumb. output_palette also required TERM to be set, so on a terminal with no TERM (env -i, some service managers, minimal containers) there were no colors. Auto mode now only turns colors off for TERM=dumb; an unset TERM keeps them.

Tests:

  • tests/by-util/test_diff.rs: the color test now also runs --color=auto ---presume-output-tty with TERM removed and expects the colored output. It fails on main and passes with this change. The existing TERM=dumb case still expects no colors.

cargo test --test tests, cargo fmt --check and cargo clippy -- -D warnings are clean. (Locally the ed_diff permutation unit tests can't run because ed isn't installed here; everything else passes.)

I used an AI assistant to write this change. I reviewed and tested it myself.

Only TERM=dumb disables colors in auto mode now, like GNU diff.
An unset TERM (env -i, service managers, minimal containers) no
longer turns colors off on a terminal.

Fixes uutils#352
Copilot AI balanced review requested due to automatic review settings November 10, 2026 20:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@sylvestre
sylvestre merged commit ab91ec9 into uutils:main Nov 10, 2026
31 checks passed
@sylvestre

Copy link
Copy Markdown
Collaborator

Thanks for your PR

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.

diff - --color=auto is disabled when TERM is unset

3 participants