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

getc function in fish? #1616

Closed
tannhuber opened this issue Aug 18, 2014 · 4 comments
Closed

getc function in fish? #1616

tannhuber opened this issue Aug 18, 2014 · 4 comments
Labels
Milestone

Comments

@tannhuber
Copy link
Contributor

@tannhuber tannhuber commented Aug 18, 2014

Is it possible to write a getc function as shown in the following link for bash?
http://osr507doc.sco.com/en/OSUserG/_How_to_get_a_character.html
If yes, how?

@ghost
Copy link

@ghost ghost commented Aug 18, 2014

Very easily; stty and dd are commands, not builtins. However, you should note that this is rather inefficient because it forks the shell twice, and I think that it'd be better if maybe read could be configured to only accept one character.

@tannhuber
Copy link
Contributor Author

@tannhuber tannhuber commented Aug 19, 2014

@Undeterminant Thank you for the answer. However, I think it's not that easy. The set command fires dd into the background:

set tmp (dd bs=1 count=1 ^/dev/null)

doesn't wait for user input. It doesn't matter whether it's raw or cooked mode.

I agree with you that a builtin option for read would be the best solution. At the moment it seems not to be possible at all.

@tannhuber
Copy link
Contributor Author

@tannhuber tannhuber commented Aug 19, 2014

In bash, there's a -n option (-k in zsh):

-n nchars
                     read  returns  after  reading  nchars  characters rather than waiting for a complete line of
                     input, but honor a delimiter if fewer than nchars characters are read before the delimiter.

Anything like that would be nice for fish as well.

@zanchey zanchey added the enhancement label Sep 15, 2014
@zanchey zanchey added this to the next-minor milestone Sep 15, 2014
@zanchey
Copy link
Member

@zanchey zanchey commented Sep 15, 2014

Closed through #1618!

@zanchey zanchey closed this Sep 15, 2014
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.