Skip to content

Commit

Permalink
cli: respect $NO_COLOR only if it's non-empty
Browse files Browse the repository at this point in the history
This is what the spec says.
  • Loading branch information
martinvonz committed Dec 7, 2024
1 parent e9cdcdc commit 0bf97a5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Fixed bugs

* The `$NO_COLOR` environment variable must now be non-empty to be respected.

## [0.24.0] - 2024-12-04

### Release highlights
Expand Down
2 changes: 1 addition & 1 deletion cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ pub fn config_from_environment(default: config::Config) -> StackedConfig {
/// Environment variables that should be overridden by config values
fn env_base() -> config::Config {
let mut builder = config::Config::builder();
if env::var("NO_COLOR").is_ok() {
if !env::var("NO_COLOR").unwrap_or_default().is_empty() {
// "User-level configuration files and per-instance command-line arguments
// should override $NO_COLOR." https://no-color.org/
builder = builder.set_override("ui.color", "never").unwrap();
Expand Down

0 comments on commit 0bf97a5

Please sign in to comment.