Giter Site home page Giter Site logo

Comments (8)

kke avatar kke commented on May 19, 2024

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

from tty-prompt.

piotrmurach avatar piotrmurach commented on May 19, 2024

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?

from tty-prompt.

piotrmurach avatar piotrmurach commented on May 19, 2024

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

from tty-prompt.

kke avatar kke commented on May 19, 2024

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)

from tty-prompt.

piotrmurach avatar piotrmurach commented on May 19, 2024

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.

from tty-prompt.

kke avatar kke commented on May 19, 2024

from tty-prompt.

piotrmurach avatar piotrmurach commented on May 19, 2024

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.

from tty-prompt.

piotrmurach avatar piotrmurach commented on May 19, 2024

@kke Released v0.11.0 with Windows support.

from tty-prompt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.