-
-
Notifications
You must be signed in to change notification settings - Fork 4k
support NO_COLOR
env var for disabling ANSI
#11398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the env variable is present, color should not be used regardless of its value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially thought the same thing. But if you carefully read the nocolor website, command line flags are supposed to override the environment variable. Because of this, the upstream change allows
with_ansi()
to override the environment variable, otherwise it wouldn’t be possible for command-line flags to override the environment variable.Longer explanation in this comment in the upstream issue for the PR tokio-rs/tracing#2388 (comment)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated: Ignore this comment; I found the reference. Leaving this incorrect info for posterity.
Bah, they literally just updated the nocolor website a week ago, and the ~~text about flag overriding has been removed. ~~
If you want to push for NO_COLOR to always override commandline flags, I’d open a new PR upstream to fix the behavior there. The reason can be that the NO_COLOR guidelines changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found it in the code block on the no-color website. It’s the comment at the bottom of their example code that says flags can override environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from my understanding the check should be on "not empty". if it's set but empty, keep the colours, if it's set and not empty, then remove the colours
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember reading the website a while back and wondering why they didn't say
NO_COLOR="true"