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

use default console in cygwin and mintty emulators on Windows #41

Closed
piotrmurach opened this issue Feb 15, 2017 · 8 comments
Closed

use default console in cygwin and mintty emulators on Windows #41

piotrmurach opened this issue Feb 15, 2017 · 8 comments
Labels

Comments

@piotrmurach
Copy link
Owner

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

@kke
Copy link
Contributor

kke commented Feb 16, 2017

I just found out that $stdXX.tty? is always false on cygwin + mintty. Don't know how to get around that.

@piotrmurach
Copy link
Owner Author

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?

@piotrmurach
Copy link
Owner Author

@kke Did you have any chance to look into this? I'm hoping to release new version this weekend.

@kke
Copy link
Contributor

kke commented Feb 24, 2017

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:
softprops/atty#12

There's some c-source here: mintty/mintty#482 (comment)

@piotrmurach
Copy link
Owner Author

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.

@kke
Copy link
Contributor

kke commented Feb 25, 2017 via email

@piotrmurach
Copy link
Owner Author

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.

@piotrmurach
Copy link
Owner Author

@kke Released v0.11.0 with Windows support.

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

No branches or pull requests

2 participants