public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* [Bug] No Keyboard input when using interactive commands with stdin via pipes
@ 2023-04-11  8:22 Wladislav Artsimovich
  2023-04-14  3:21 ` Takashi Yano
  0 siblings, 1 reply; 2+ messages in thread
From: Wladislav Artsimovich @ 2023-04-11  8:22 UTC (permalink / raw)
  To: cygwin

Dear Cygwin users,
 
there appears to be a bug or a missing implementation detail in either unix pipes or ConPTY, which prevents interactive console programs from receiving keyboard input, when they get stdin via a pipe.
This report concerns the following Github issue, originally started in the MinTTY Terminal emulator Repo: https://github.com/mintty/mintty/issues/1210
 
There are multiple programs, which fail to receive any kind of keyboard input when used in MinTTY and when their stdin input is supplied via a pipe.
This has been reported multiple times in the MinTTY repo already.
 
Examples include: 
 - `fzf`, which works normally when being called, but stops working properly if it receives a file list via a pipe. Eg.: `fzf` by itself works fine. but `find . | fzf` fails.
 - By extension, the zsh plugin fzf-plugin fails for the same reason, when opening the command history
 - The program fx ( https://github.com/antonmedv/fx ) which successfully receives keyboard input for navigating a json file, Eg.: `curl -s https://api.openai.com/v1/chat/completions -H 'Content-Type: application/json' > test.json; fx test.json` but fails when getting the json data as a direct pipe: `curl -s https://api.openai.com/v1/chat/completions -H 'Content-Type: application/json' | fx`
 
This happens with MinTTY accessing the MSYS2 environment on Windows. Interestingly enough, this does not happen with Alacritty accessing the MSYS2 environment on Windows. With Alacritty everything is fine, which made me initially suspect MinTTY as being the culprit. However, the MinTTY repo lead diagnosed this issue to come from Cygwin, which is why I write report the bug in this mailing list.
 
Is there something that can be done about this? Can I provide additional debug info or logs to help fix this?
 
Best regards,
 
Vlad

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Bug] No Keyboard input when using interactive commands with stdin via pipes
  2023-04-11  8:22 [Bug] No Keyboard input when using interactive commands with stdin via pipes Wladislav Artsimovich
@ 2023-04-14  3:21 ` Takashi Yano
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Yano @ 2023-04-14  3:21 UTC (permalink / raw)
  To: cygwin; +Cc: Wladislav Artsimovich

On Tue, 11 Apr 2023 08:22:25 +0000
Wladislav Artsimovich wrote:
> Dear Cygwin users,
>  
> there appears to be a bug or a missing implementation detail in either unix pipes or ConPTY, which prevents interactive console programs from receiving keyboard input, when they get stdin via a pipe.
> This report concerns the following Github issue, originally started in the MinTTY Terminal emulator Repo: https://github.com/mintty/mintty/issues/1210
>  
> There are multiple programs, which fail to receive any kind of keyboard input when used in MinTTY and when their stdin input is supplied via a pipe.
> This has been reported multiple times in the MinTTY repo already.
>  
> Examples include: 
>  - `fzf`, which works normally when being called, but stops working properly if it receives a file list via a pipe. Eg.: `fzf` by itself works fine. but `find . | fzf` fails.
>  - By extension, the zsh plugin fzf-plugin fails for the same reason, when opening the command history
>  - The program fx ( https://github.com/antonmedv/fx ) which successfully receives keyboard input for navigating a json file, Eg.: `curl -s https://api.openai.com/v1/chat/completions -H 'Content-Type: application/json' > test.json; fx test.json` but fails when getting the json data as a direct pipe: `curl -s https://api.openai.com/v1/chat/completions -H 'Content-Type: application/json' | fx`
>  
> This happens with MinTTY accessing the MSYS2 environment on Windows. Interestingly enough, this does not happen with Alacritty accessing the MSYS2 environment on Windows. With Alacritty everything is fine, which made me initially suspect MinTTY as being the culprit. However, the MinTTY repo lead diagnosed this issue to come from Cygwin, which is why I write report the bug in this mailing list.
>  
> Is there something that can be done about this? Can I provide additional debug info or logs to help fix this?

Thnaks for the report.

I cound reproduce your problem by:
$ yes | cat -n | more.com
(not /usr/bin/more but /cygdrive/c/WINDOWS/system32/more.com)

Currently, the keybord inputs are sent only to 'yes' rather than 'more.com'
in the above case.

This does not happen in:
$ yes | cat -n | less
because less is a cygwin program which opens '/dev/tty' rather than 'CONIN$'.

Anyway, I'll fix that.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-14  3:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-11  8:22 [Bug] No Keyboard input when using interactive commands with stdin via pipes Wladislav Artsimovich
2023-04-14  3:21 ` Takashi Yano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).