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

win32: Detect Cygwin/MSYS PTY #1099

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

k-takata
Copy link
Contributor

@k-takata k-takata commented Jun 1, 2017

When running Win32 version of Ag on mintty or other Cygwin/MSYS terminal
emulators, Ag cannot detect Cygwin/MSYS pty and it causes some problems.
E.g.
#535 (comment)
msys2/MSYS2-packages#491

Import a check routine from https://github.com/k-takata/ptycheck .

k-takata added a commit to k-takata/MINGW-packages that referenced this pull request Jun 5, 2017
* Update to 2.0.0.
* Import a patch to detect mintty from ggreer/the_silver_searcher#1099.
  This fixes a well known problem which has been reported many times:
  msys2#431, msys2/MSYS2-packages#491, etc.
k-takata added 3 commits June 6, 2017 23:09
When running Win32 version of Ag on mintty or other Cygwin/MSYS terminal
emulators, Ag cannot detect Cygwin/MSYS pty and it causes some problems.
E.g.
ggreer#535 (comment)
msys2/MSYS2-packages#491

Import a check routine from https://github.com/k-takata/ptycheck .
Don't know why clang-format on Travis complains this.
@k-takata k-takata force-pushed the detect-cygwin-pty branch from 5432bdc to e1e7212 Compare June 6, 2017 14:09
Alexpux pushed a commit to msys2/MINGW-packages that referenced this pull request Jun 7, 2017
* Update to 2.0.0.
* Import a patch to detect mintty from ggreer/the_silver_searcher#1099.
  This fixes a well known problem which has been reported many times:
  #431, msys2/MSYS2-packages#491, etc.
stahta01 pushed a commit to stahta01/MINGW-packages that referenced this pull request Jun 8, 2017
* Update to 2.0.0.
* Import a patch to detect mintty from ggreer/the_silver_searcher#1099.
  This fixes a well known problem which has been reported many times:
  msys2#431, msys2/MSYS2-packages#491, etc.
@avih
Copy link
Contributor

avih commented Aug 30, 2017

@k-takata, I submitted #1146 without noticing this PR. One of its commits (win32: detect and use normal ansi on msys2/cygwin tty) seem to me pretty much identical to this one, but I think it's simpler.

Would you object if we go ahead with #1146 instead of this? Do you notice any functional differences other than the ones I mentioned at #1146 (comment) ?

Fix potential buffer overflow.
@avih
Copy link
Contributor

avih commented Sep 7, 2017

@k-takata ping on my last question? any reason to prefer a solution with an order of magnitude more lines of code (and affected files and build procedure), which does basically the same as a much smaller solution?

@k-takata
Copy link
Contributor Author

k-takata commented Sep 7, 2017

I'll leave the decision to @ggreer .

@avih
Copy link
Contributor

avih commented Sep 7, 2017

But it's not only about this PR for ag. You use a variant of your fix in several other places in msys2 too. It's a big chunk of code which can really be much smaller and simpler. Don't you prefer smaller if it does the same thing?

@k-takata also, he didn't send the PR, you did. So I'm asking whether you think there's a reason to prefer this PR over #1146 ?

@k-takata
Copy link
Contributor Author

k-takata commented Sep 8, 2017

Iscygpty is intended to be easily included in other software including non-MSYS2 software. The user should just include the two files into the project, add #include "iscygpty.h" and call is_cygpty() where needed.
The code should be configurable because it totally depends on the software whether support for WinXP is needed or not, or dynamic loading is needed or not. LOC is not important here.

@avih
Copy link
Contributor

avih commented Sep 11, 2017

it totally depends on the software whether support for WinXP is needed or not, or dynamic loading is needed or not

This is partially off topic for ag, but Microsoft doesn't support XP anymore, and as far as I know neither do Msys2 nor cygwin. Therefore, jumping through hoops to support XP is, IMO, not required, because there's no current use case where a cygwin/msys2 tty exists on XP.

As for dynamic loading, it's a 5 lines function (after you remove XP support and the other redundant stuff). I don't think there's a good use case for dynamic loading. Note that the dynamic loading support is for DLLs which are used by the detection and are only required to enable the detection on XP. It's not for putting cygpty itself as a DLL. So if we ignore XP, there's no need for the dynamic loading code either.

And, specifically for ag, while you might want to provide XP support and other features when you use such patch downstream (e.g. in Msys2), imposing all of this on upstream is a lot of code for an unsupported use case - msys/cygwin on XP.

As a side note, and this is off topic for ag, I think the cygpty downstream msys2 patches (you mentioned vim and others) should also drop XP and simplify the code, because msys2 itself doesn't support XP anymore - again - as far as I know.

@k-takata
Copy link
Contributor Author

At least Vim still wants to support XP, so removing such configuration is not an option for iscygpty.

@avih
Copy link
Contributor

avih commented Sep 11, 2017

At least Vim still wants to support XP, so removing such configuration is not an option for iscygpty.

I'm pretty sure the msys2/mingw vim binary you build with the cygpty patch doesn't run on xp anyway. And even if it does, there's no value in the cygpty detection since msys2/cygwin don't run on XP.

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

Successfully merging this pull request may close these issues.

2 participants