Skip to content

Commit d62bbbb

Browse files
authored
Merge pull request #1421 from acuteenvy/fix-no-color
fix: display color when `NO_COLOR` is an empty string
2 parents 8bbbd76 + ad5fb44 commit d62bbbb

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
## Bugfixes
1010

11+
- Fix `NO_COLOR` support, see #1421 (@acuteenvy)
12+
1113
## Changes
1214

1315
- The default number of threads is now constrained to be at most 16. This should improve startup time on

src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,13 @@ fn construct_config(mut opts: Opts, pattern_regexps: &[String]) -> Result<Config
218218
let ansi_colors_support = true;
219219

220220
let interactive_terminal = std::io::stdout().is_terminal();
221+
221222
let colored_output = match opts.color {
222223
ColorWhen::Always => true,
223224
ColorWhen::Never => false,
224225
ColorWhen::Auto => {
225-
ansi_colors_support && env::var_os("NO_COLOR").is_none() && interactive_terminal
226+
let no_color = env::var_os("NO_COLOR").is_some_and(|x| !x.is_empty());
227+
ansi_colors_support && !no_color && interactive_terminal
226228
}
227229
};
228230

0 commit comments

Comments
 (0)