Skip to content

Commit

Permalink
Merge pull request #2469 from aloucks/msys-disable-color
Browse files Browse the repository at this point in the history
Disable broken color in MSYS2 shells.
  • Loading branch information
rbtcollins authored Aug 28, 2020
2 parents d08b309 + 557e2df commit 94362b5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils/tty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ pub fn stderr_isatty() -> bool {
isatty(libc::STDERR_FILENO)
}

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

0 comments on commit 94362b5

Please sign in to comment.