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

reader_readline only ever reads from fish's STDIN #7358

Closed
faho opened this issue Sep 28, 2020 · 2 comments
Closed

reader_readline only ever reads from fish's STDIN #7358

faho opened this issue Sep 28, 2020 · 2 comments

Comments

@faho
Copy link
Member

faho commented Sep 28, 2020

Via gitter we got a question about a git commit-msg hook.

These run in an environment with a non-tty stdin, so if you want to query the user, you'd have to read </dev/tty explicitly. See e.g. https://stackoverflow.com/questions/3417896/how-do-i-prompt-the-user-from-within-a-commit-msg-hook.

Only that won't work in fish, because even tho read receives the redirected fd, it'll call reader_readline, and that has hard-coded 0 pretty extensively (down to input_event_queue_t::readb using FD_SET(0, &fdset)).

It would be great if this worked.

@faho faho added this to the fish-future milestone Sep 28, 2020
@mqudsi
Copy link
Contributor

mqudsi commented Oct 3, 2020

I've had to resort to using /dev/tty a lot in my fish scripts for a few other cases as well, but it's important to note that it's not just unfriendly but also unportable since I think it's a Linux-only thing.

@faho
Copy link
Member Author

faho commented Oct 3, 2020

Sure, but:

  1. This is about read reading interactively from anything, not just /dev/tty specifically
  2. In this context you need to set the tty manually, so if you don't have /dev/tty you just need to pass it differently

I'm not asking for us to use this anywhere, I'm asking for us to make it possible.

@faho faho closed this as completed in 0951a70 Oct 31, 2020
@zanchey zanchey modified the milestones: fish-future, fish 3.2.0 Nov 4, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants