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

-Q not work correctly with ugrep built using mingw32 gcc on Windows #307

Closed
jack6th opened this issue Oct 23, 2023 · 4 comments
Closed

-Q not work correctly with ugrep built using mingw32 gcc on Windows #307

jack6th opened this issue Oct 23, 2023 · 4 comments

Comments

@jack6th
Copy link

jack6th commented Oct 23, 2023

I compiled a win32 ugrep.exe using mingw32 gcc on Windows.
(ugrep v4.3.1, i686-w64-mingw32, gcc v13.2.0)
Without -Q it works. (eg. ugrep -e pattern filename.txt)
On cmd.exe, conemu.exe and mintty.exe I tried command below all get the error message.

# on conemu.exe & mintty.exe
$ugrep -Q filename.txt
ugrep: no ANSI terminal keyboard detected
# on cmd.exe
$ugrep -Q filename.txt
←[mugrep: ←[1;31mno ANSI terminal keyboard detected←[m

Is the issue like BurntSushi/ripgrep#94 and BurntSushi/ripgrep#117 ?

@genivia-inc
Copy link
Member

genivia-inc commented Oct 23, 2023

Cygwin works. The -Q option checks terminal properties (screen and keyboard). If either fails, then it gives up. In this case the keyboard input isn't detected as a tty device or standard input is not a tty in vkey.cpp function setup:

  tty = open("/dev/tty", O_RDWR);

  if (tty < 0)
  {
    if (isatty(STDIN_FILENO) == 0)
      return false;
    tty = STDIN_FILENO;
  }

Could be something as simple as isatty() failing.

@genivia-inc
Copy link
Member

Actually kind of strange that I have not trouble with ugrep running in Cygwin when in your case MinGW fails. Since Cygwin isatty() is fine (as it is likely just calling Windows _isatty()), why wouldn't MinGW not work too? I don't have MinGW installed to check for details. This has nothing to do with the ripgrep bug 117, which in ugrep works fine using isatty() on standard output (instead of standard input in vkey.cpp) and combing some special code for Windows console checking.

@genivia-inc
Copy link
Member

What is your Windows OS version?

If your Windows OS version is 7 or even older, then we already know -Q will not work and this is not fixable, see #142 #84.

@jack6th
Copy link
Author

jack6th commented Oct 24, 2023

Thanks for your reply.
My OS is Windows 7 SP1 32bit.
I recompiled ugrep with MSYS2 32bit and now -Q works.

@jack6th jack6th closed this as completed Oct 24, 2023
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

No branches or pull requests

2 participants