Your question, of course, is quite a good one. But there really
is a reason why I THINK I should do it this way.
I have written what amounts to a process-control program, and it
works quite well. Except for one problem: Rather inexperienced people will
have access to the keyboard and the display. Single
key pushes will determine the direction and amplitude of the process. But some
of the operators will make mistakes on the keyboard, and the processes need to
be protected from those mistakes. Control-C, for example, could bring the
program to a halt, with potentially devastating effects on the process under
control. And worse, some of these people have nothing good to say about
computers, and would be quite happy to see the entire "computer-control"
approach come to an inglorious end. Those types can probably be counted on to
"experiment" with undefined key strokes.
Clearly, some protection from "dis-allowed" keystrokes needs to be
built in. I wrote the original working program in gforth. But
the only potentially-available keyboard protection I know about in
Forth seems too inadequate. But in shell scripts you have the TRAP command,
which looks ideal for disallowing dangerous keystrokes. So I thought I might
well revert to the script level for this application (which does not require
blazing speed).
If you know of another, wiser, route to take, I would be very grateful to hear
about it. It even seems to me that this specific problem should be widespread
in computer applications; there ought to be some frequently-used solutions. But
I have not found any, despite a lot of hunting. But sadly, I am not any kind of
programming expert :)