Skip to content

Commit 28a2807

Browse files
committed
differentiate between CLICOLOR values
1 parent 64add74 commit 28a2807

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cli/src/main.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1286,17 +1286,17 @@ fn should_use_color() -> bool {
12861286
return false;
12871287
}
12881288

1289-
// Then check CLICOLOR_FORCE - if set, enable colors regardless of terminal
1290-
if std::env::var_os("CLICOLOR_FORCE").is_some() {
1289+
// Then check CLICOLOR_FORCE - if set and not empty/"0", enable colors regardless of terminal
1290+
if std::env::var_os("CLICOLOR_FORCE").is_some_and(|e| !e.is_empty() && e != "0") {
12911291
return true;
12921292
}
12931293

1294-
// Check CLICOLOR - if set, use colors only when writing to a terminal
1295-
if std::env::var_os("CLICOLOR").is_some() {
1294+
// Check CLICOLOR - if set and not empty/"0", use colors only when writing to a terminal
1295+
if std::env::var_os("CLICOLOR").is_some_and(|e| !e.is_empty() && e != "0") {
12961296
return std::io::stdout().is_terminal();
12971297
}
12981298

1299-
// Modern default (acting as if CLICOLOR is set):
1299+
// Modern default (acting as if CLICOLOR is set)
13001300
std::io::stdout().is_terminal()
13011301
}
13021302

0 commit comments

Comments
 (0)