SYSV version of \"grabchars.c\".
Ubben Greg
bink at aplcen.apl.jhu.edu
Sat May 6 16:30:28 AEST 1989
In article <19462 at adm.BRL.MIL> mark at ria-emh2.army.mil (Mark D. McKamey) writes:
> I have recently recieved a copy of Mr. Dan Smith's "grabchars" program
> which allows you to get one or more keystrokes from the user, without
> requiring them to hit RETURN within a shell script. The problem I have is
> that the program was written for BSD UNIX. Has anyone ported said program
> to SYSV UNIX? If so, would you please send me the SYSV patches. Thank You.
I wrote a System V script to allow single-keystroke input too, and came
up with a more general solution (not requiring the "grabchars" program).
I first used the stty command to allow reading single character responses.
Something like "stty -icanon min '^a'" but I don't have AFSVM handy, so
this is probably wrong. Be sure to use stty -g to save the current modes
in a variable first, and set up a trap to restore them. Then the only way I
found to actually read one character without a newline was to use a "head"
program I wrote (before I gnu about knew). The code looked something like:
case `head -1c` in
[Yy])
...
[Nn])
...
I would expect that GNU head could be used the same way. Multi-sequence
keys would fool it (such as function keys) -- does grabchars handle this?
Is there a better way yet (in shell)?
-- Greg Ubben
bink at aplcen.apl.jhu.edu
More information about the Comp.unix.questions
mailing list