Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipes detected as a tty on MSYS #23

Closed
alexcrichton opened this issue Mar 5, 2018 · 0 comments
Closed

Pipes detected as a tty on MSYS #23

alexcrichton opened this issue Mar 5, 2018 · 0 comments

Comments

@alexcrichton
Copy link
Contributor

I've initially attempted to integrate atty/termcolor into rustc at rust-lang/rust#48588 but unfortunately it looks like there may be a misdiagnosis of terminal colors! It looks like in the MSYS terminal/shell pipes are classified as ttys, for example this program:

extern crate atty;
fn main() {
    println!("stdin:  {}", atty::is(atty::Stream::Stdin));
    println!("stdout: {}", atty::is(atty::Stream::Stdout));
    println!("stderr: {}", atty::is(atty::Stream::Stderr));
}

Will print:

$ echo a | cargo run 2>&1 | cat
stdin:  true
stdout: true
stderr: true

when run in MSYS.

The same program for Unix, however, prints:

$ echo a | cargo run 2>&1 | cat
stdin:  false
stdout: false
stderr: false

With some debugging it looks like the filename reported for the MSYS pipes are along the lines of:

"\\msys-dd50a72ab4668b33-2996-pipe-0x5A"
"\\msys-dd50a72ab4668b33-2996-pipe-0x5C"

which looks to trigger this logic. Was the || there supposed to be &&?

alexcrichton added a commit to alexcrichton/atty that referenced this issue Mar 5, 2018
The MSYS terminal appears to create pipes with the name `msys-` but *don't*
contain `-pty`, so this changes the `||` logic to `&&` to ensure that the logic
here doesn't fire for MSYS terminals where piping is used to erroneously
diagnose a stdio stream as a tty.

Closes softprops#23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant