Skip to content

Commit

Permalink
Make RUSTUP_TERM_COLOR's value case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Aug 15, 2023
1 parent 106b9c3 commit b6cf380
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/currentprocess/terminalsource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ impl ColorableTerminal {
/// then color commands will be sent to the stream.
/// Otherwise color commands are discarded.
pub(super) fn new(stream: StreamSelector) -> Self {
let env_override = process().var("RUSTUP_TERM_COLOR");
let env_override = process()
.var("RUSTUP_TERM_COLOR")
.map(|it| it.to_lowercase());
let choice = match env_override.as_deref() {
Ok("always") => ColorChoice::Always,
Ok("never") => ColorChoice::Never,
Expand Down Expand Up @@ -260,24 +262,24 @@ mod tests {
}

assert_color_choice(
"always",
"aLWayS",
StreamSelector::TestWriter(Default::default()),
ColorChoice::Always,
);
assert_color_choice(
"never",
"neVer",
StreamSelector::TestWriter(Default::default()),
ColorChoice::Never,
);
// tty + `auto` enables the colors.
assert_color_choice(
"auto",
"AutO",
StreamSelector::TestTtyWriter(Default::default()),
ColorChoice::Auto,
);
// non-tty + `auto` does not enable the colors.
assert_color_choice(
"auto",
"aUTo",
StreamSelector::TestWriter(Default::default()),
ColorChoice::Never,
);
Expand Down

0 comments on commit b6cf380

Please sign in to comment.