Closed piotrmurach closed 7 years ago
I just found out that $stdXX.tty?
is always false on cygwin + mintty. Don't know how to get around that.
That's quite unexpected behaviour. I would be curious to find out what RUBY_PLATFORM
returns in cygwin & mintty. Whether there is a way to determine cygwin from that value?
Alternatively, I think we could detect what is being used by calling some utility functions. Kind of like features sniffing. For example, cygwin comes with cygcheck
utility that we could call:
system('cygcheck --version') # returns true if exits with 0 status or nil otherwise
Same for the mintty
system('mintty --version') # true or nil
Obviously it is not the most optimum solution as there is more emulators out there but hopefully would make it work for majority of Windows users and with time we could refine it. This feature detection shouldn't make the tool slower as this check is only performed when you create the prompt instance.
Would you mind checking this theory?
@kke Did you have any chance to look into this? I'm hoping to release new version this weekend.
Seems like it's a problem for a lot of projects. Git for windows has solved it with some strange hackery: http://git.661346.n2.nabble.com/PATCH-mingw-make-isatty-recognize-MSYS2-s-pseudo-terminals-dev-pty-td7654456.html
Here's some rust tty package pull request that fixed it: https://github.com/softprops/atty/pull/12
There's some c-source here: https://github.com/mintty/mintty/issues/482#issuecomment-265844179
I think there are two issues that we are discussing here. Original issue was to correctly recognise whether this library has to use Unix console capabilities or Windows specific api. The problem was if I understood correctly that everything works fine in Windows console/powershell. However things stop working fine when Cygwin/mintty are used as tty-prompt
assumes windows environment and ideally would run as if standard unix console is present. That is why I suggested to run specific utilities to figure this stuff out.
In other words, this gem doesn't care what tty?
value is as it is not used for anything in the code base. It is down to client to figure out whether it is dealing with console, file io or some other thing. tty-prompt
prints to standard out by default wherever that may be. You can pass :stdin
parameter to instruct to output to whatever but it is not the concern of this library per se.
Nothing works in mintty without some wizardry, mintty is "broken" (I suppose it's one those feature vs bug type of things. Separate issue anyways.)
On Feb 25, 2017 02:02, "Piotr Murach" notifications@github.com wrote:
I think there are two issues that we are discussing here. Original issue was to correctly recognise whether this library has to use Unix console capabilities or Windows specific api. The problem was if I understood correctly that everything works fine in Windows console/powershell. However things stop working fine when Cygwin/mintty are used as tty-prompt assumes windows environment and ideally would run as if standard unix console is present. That is why I suggested to run specific utilities to figure this stuff out.
In other words, this gem doesn't care what tty? value is as it is not used for anything in the code base. It is down to client to figure out whether it is dealing with console, file io or some other thing. tty-prompt prints to standard out by default wherever that may be. You can pass :stdin parameter to instruct to output to whatever but it is not the concern of this library per se.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/piotrmurach/tty-prompt/issues/41#issuecomment-282438436, or mute the thread https://github.com/notifications/unsubscribe-auth/AANuy9hocHIQmMjnABqQEQikhoCpCUQVks5rf2-bgaJpZM4MCYom .
I have changed windows?
check. Instead of checking for operating system, it looks at Ruby file feature. This is based on the observation that if cygwin is installed it will require its own Ruby installation which will be unix compatible. Therefore this should work fine on Unix flavoured emulators in Windows.
@kke Released v0.11.0
with Windows support.
I think your
windows?
is true for cygwin (or MinTTY which also comes with git for windows). Seems like the windows keyreader does not work under it. (the normal non-windows stuff should work fine) by @kke