Skip to content

Commit 94362b5

Browse files
authored
Merge pull request #2469 from aloucks/msys-disable-color
Disable broken color in MSYS2 shells.
2 parents d08b309 + 557e2df commit 94362b5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/utils/tty.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ pub fn stderr_isatty() -> bool {
44
isatty(libc::STDERR_FILENO)
55
}
66

7-
// FIXME: Unfortunately this doesn't detect msys terminals so rustup
8-
// is always colorless there (just like rustc and cargo).
97
#[cfg(windows)]
108
pub fn stderr_isatty() -> bool {
119
isatty(winapi::um::winbase::STD_ERROR_HANDLE)
@@ -30,6 +28,11 @@ fn isatty(fd: libc::c_int) -> bool {
3028
#[inline]
3129
#[cfg(windows)]
3230
fn isatty(fd: winapi::shared::minwindef::DWORD) -> bool {
31+
if std::env::var("MSYSTEM").is_ok() {
32+
// FIXME: No color is better than broken color codes in MSYS shells
33+
// https://github.com/rust-lang/rustup/issues/2292
34+
return false;
35+
}
3336
use winapi::um::{consoleapi::GetConsoleMode, processenv::GetStdHandle};
3437
unsafe {
3538
let handle = GetStdHandle(fd);

0 commit comments

Comments
 (0)