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

winpty: auto-detect redirects of stdin/stdout #415

Closed
wants to merge 1 commit into from

Conversation

rimrul
Copy link
Member

@rimrul rimrul commented May 3, 2022

Running commands through winpty with a redirected stdin or
stdout only leads to error messages, that are at best not very
helpful to users and at worst outright confusing users.
We can do better by adding a thin wrapper script that detects
when it is and isn't appropriate to run a command through winpty
and acts accordingly.

This is an alternative to #414 that doesn't use undocumented options and shouldn't cause commands to think they're outputting to a console when they aren't.

@rimrul rimrul requested a review from dscho May 3, 2022 09:31
@dscho
Copy link
Member

dscho commented May 3, 2022

That's an interesting idea!

However, I would like to see this in winpty.exe directly, rather than requiring a shell script wrapper (these things really bring a performance hit with them, on Windows).

I'd be totally willing to carry a patch in MSYS2-packages/winpty/ and build our own versions of the winpty package, but I could also imagine that the MSYS2 project would be quite keen on that.

What I have in mind is a new option that opts out of this new handling, so that by default we're checking isatty(0) && isatty(1) and if either one is redirected, simply spawn the child process with inherited handles (so that we do not have to pipe stdin/stdout/stderr back and forth) and skip the rest of winpty.

What do you think @rimrul?

Running commands through winpty with a redirected stdin or
stdout only leads to error messages, that are at best not very
helpfull to users and at worst outright confusing users.
We can do better by adding a thin wrapper script that detects
when it is and isn't appropriate to run a command through winpty
and acts accordingly.

Signed-off-by: Matthias Aßhauer <mha1993@live.de>
@rimrul
Copy link
Member Author

rimrul commented May 3, 2022

these things really bring a performance hit with them, on Windows

I've assumed the performance impact to be negligible when executing a shell script in bash, but you're probably right, this is probably a whole new bash proccess, just for this.

I could also imagine that the MSYS2 project would be quite keen on that.

That definitely sounds plausible.

What do you think @rimrul?

I'll see what I can do.

@dscho
Copy link
Member

dscho commented May 3, 2022

What do you think @rimrul?

I'll see what I can do.

Thank you!

@rimrul rimrul closed this Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants