Dears,
I just pushed on my website a litte function to ``read'' any keyboard
key during specific interval:
https://f-hauri.ch/vrac/getKeyInterval.sh
As Greg suggest, I use ``stty'' to be able to trap `Ctrl-C`, but `Ctrl-Z`,
`Ctrl-S` and `Ctrl-Q` too.
Let me know if something seem not correct, wrong or overkill!
Note: I wrote this first for playing with OpenSSL and shadow password files:
https://f-hauri.ch/vrac/password.sh
And added interval for my snake bash game:
https://f-hauri.ch/vrac/snake.sh
Le Mon, Jun 22, 2026 at 11:30:34AM -0400, Greg Wooledge a écrit :
> On Mon, Jun 22, 2026 at 09:16:03 -0600, Stan Marsh wrote:
> > That is certainly interesting, but it doesn't fit my use case and is
> > obviously more complicated than this ought to be (*).
>
> What *is* your use case?
>
> > My main question is more of a "why": Why does it not work the way it
> > should? Why is ^C ignored when inside a "read" ?
>
> Because you trapped the signal it generates.
>
> > (*) And quite a bit more complicated than my original posted solution.
>
> I disagree. stty is much simpler (in terms of rolling out this script)
> than a custom C program that injects bytes into a pseudoterminal.
>
--
Félix Hauri - <felix@f-hauri.ch> - http://www.f-hauri.ch
[Prev in Thread]
Current Thread
[Next in Thread]
Re: Exiting the "read" builtin with trapped ^C,
Félix Hauri<=