From 52210fed1543d55c9f98771c6c1b9ac07b235572 Mon Sep 17 00:00:00 2001 From: Lena <126529524+acuteenvy@users.noreply.github.com> Date: Sat, 4 Nov 2023 13:46:45 +0100 Subject: [PATCH] Enable color outputting when `NO_COLOR` is empty --- src/util.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util.rs b/src/util.rs index d5fb35f..4bd032f 100644 --- a/src/util.rs +++ b/src/util.rs @@ -122,11 +122,13 @@ pub fn init_color(color_mode: ColorChoice) { #[cfg(not(target_os = "windows"))] let color_support = true; + let no_color = env::var_os("NO_COLOR").is_some_and(|x| !x.is_empty()); + match color_mode { ColorChoice::Always => {} ColorChoice::Never => Paint::disable(), ColorChoice::Auto => { - if !(color_support && env::var_os("NO_COLOR").is_none() && io::stdout().is_terminal()) { + if !(color_support && !no_color && io::stdout().is_terminal()) { Paint::disable(); } }