Skip to content

Commit

Permalink
Ignore NO_COLOR if set to empty string
Browse files Browse the repository at this point in the history
Environment variables can have no value at all or they can have the
empty string as a value. We used to disable color if `$NO_COLOR` were
set at all, regardless of its value, but as of
jcs/no_color@99f90e2
we should ignore empty strings (and this makes more sense).

Result: `NO_COLOR= xh` now allows colors.
  • Loading branch information
blyxxyz committed Jun 4, 2024
1 parent 61c0154 commit 759a339
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl Buffer {
// Based on termcolor's logic for ColorChoice::Auto
if cfg!(test) {
Pretty::All
} else if var_os("NO_COLOR").is_some() {
} else if var_os("NO_COLOR").is_some_and(|val| !val.is_empty()) {
Pretty::Format
} else {
match var_os("TERM") {
Expand Down

0 comments on commit 759a339

Please sign in to comment.