Skip to content

Commit f9066cc

Browse files
committed
Port rust-lang/rust#119664 to is-terminal.
Port rust-lang/rust#119664 to is-terminal. The commit message is: Fix msys2 tty detection for /dev/ptmx Our "true negative" detection assumes that if at least one std handle is a Windows console then no other handle will be a msys2 tty pipe. This turns out to be a faulty assumption in the case of `/dev/ptmx`.
1 parent 8dafe57 commit f9066cc

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

src/lib.rs

+1-15
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl<Stream: AsHandle> IsTerminal for Stream {
106106

107107
// The Windows implementation here is copied from `handle_is_console` in
108108
// library/std/src/sys/pal/windows/io.rs in Rust at revision
109-
// 99128b7e45f8b95d962da2e6ea584767f0c85455.
109+
// e74c667a53c6368579867a74494e6fb7a7f17d13.
110110

111111
#[cfg(windows)]
112112
fn handle_is_console(handle: BorrowedHandle<'_>) -> bool {
@@ -128,20 +128,6 @@ fn handle_is_console(handle: BorrowedHandle<'_>) -> bool {
128128
return true;
129129
}
130130

131-
// At this point, we *could* have a false negative. We can determine that this is a true
132-
// negative if we can detect the presence of a console on any of the standard I/O streams. If
133-
// another stream has a console, then we know we're in a Windows console and can therefore
134-
// trust the negative.
135-
for std_handle in [STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, STD_ERROR_HANDLE] {
136-
let std_handle = GetStdHandle(std_handle);
137-
if std_handle != 0
138-
&& std_handle != handle as HANDLE
139-
&& GetConsoleMode(std_handle, &mut out) != 0
140-
{
141-
return false;
142-
}
143-
}
144-
145131
// Otherwise, we fall back to an msys hack to see if we can detect the presence of a pty.
146132
msys_tty_on(handle as HANDLE)
147133
}

0 commit comments

Comments
 (0)