Skip to content

Commit b6cf380

Browse files
committed
Make RUSTUP_TERM_COLOR's value case insensitive
1 parent 106b9c3 commit b6cf380

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/currentprocess/terminalsource.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ impl ColorableTerminal {
8383
/// then color commands will be sent to the stream.
8484
/// Otherwise color commands are discarded.
8585
pub(super) fn new(stream: StreamSelector) -> Self {
86-
let env_override = process().var("RUSTUP_TERM_COLOR");
86+
let env_override = process()
87+
.var("RUSTUP_TERM_COLOR")
88+
.map(|it| it.to_lowercase());
8789
let choice = match env_override.as_deref() {
8890
Ok("always") => ColorChoice::Always,
8991
Ok("never") => ColorChoice::Never,
@@ -260,24 +262,24 @@ mod tests {
260262
}
261263

262264
assert_color_choice(
263-
"always",
265+
"aLWayS",
264266
StreamSelector::TestWriter(Default::default()),
265267
ColorChoice::Always,
266268
);
267269
assert_color_choice(
268-
"never",
270+
"neVer",
269271
StreamSelector::TestWriter(Default::default()),
270272
ColorChoice::Never,
271273
);
272274
// tty + `auto` enables the colors.
273275
assert_color_choice(
274-
"auto",
276+
"AutO",
275277
StreamSelector::TestTtyWriter(Default::default()),
276278
ColorChoice::Auto,
277279
);
278280
// non-tty + `auto` does not enable the colors.
279281
assert_color_choice(
280-
"auto",
282+
"aUTo",
281283
StreamSelector::TestWriter(Default::default()),
282284
ColorChoice::Never,
283285
);

0 commit comments

Comments
 (0)