Skip to content

Respect NO_COLOR for [bat error] and [bat warning] prefixes - #4048

Merged
keith-hall merged 3 commits into
sharkdp:masterfrom
qodelicious:fix/no-color-error-prefix
Nov 2, 2026
Merged

keith-hall merged 3 commits into
sharkdp:masterfrom
qodelicious:fix/no-color-error-prefix

Conversation

@qodelicious

Copy link
Copy Markdown
Contributor

bat honors NO_COLOR for its output, but the [bat error] and [bat warning] prefixes on stderr were always painted red/yellow:

$ NO_COLOR=1 bat nonexistent 2>&1 | cat -v
^[[31m[bat error]^[[0m: 'nonexistent': No such file or directory (os error 2)

This adds a small paint_prefix helper in src/error.rs, used by default_error_handler and the bat_warning! macro, that leaves the prefix uncolored when NO_COLOR is set to a non-empty value (the same check bat already uses in env_no_color).

qodelicious added a commit to qodelicious/bat that referenced this pull request Oct 8, 2026
The error and warning prefixes were always painted red/yellow, even
when NO_COLOR is set, which bat otherwise honors for its output.
@qodelicious
qodelicious force-pushed the fix/no-color-error-prefix branch from fe9eafb to c199cc4 Compare October 18, 2026 07:09
@keith-hall
keith-hall enabled auto-merge November 2, 2026 19:52
@keith-hall
keith-hall merged commit 67e2ec2 into sharkdp:master Nov 2, 2026
24 checks passed
cindykrafft pushed a commit to cindykrafft/bat that referenced this pull request Nov 2, 2026
Brings in sharkdp#4038, sharkdp#4048 and sharkdp#4070. The merge of sharkdp#4048 re-added the old
UTF-16BE CHANGELOG entry with its "#XXXX" placeholder at the top of
Bugfixes, so drop that duplicate; the entry this PR corrects to sharkdp#4076
stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VVn4SeAXPsUajXT2rtHQfo
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.

2 participants