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?
to your account
Is it possible to write a getc function as shown in the following link for bash?
If yes, how?
The text was updated successfully, but these errors were encountered:
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.
Sorry, something went wrong.
@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.
In bash, there's a -n option (-k in zsh):
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.
Closed through #1618!
No branches or pull requests