Clearing the input buffer before a read.
Paul Chamberlain
tif at doorstop.austin.ibm.com
Tue Nov 27 03:36:04 AEST 1990
In article <1990Nov26.001425.15563 at massey.ac.nz> K.Spagnolo at massey.ac.nz (Ken Spagnolo) writes:
>I want to
>be able to flush the input buffer just before the read ...
This is pretty nasty but it might do what you want:
old_modes=`stty -g` # save old modes
stty -icanon min '^@' time '^@' # read whats already there
read junk # read all thats waiting
stty $old_modes # restore old modes
You may want to make this bullet-proof about interrupts though.
I tried this on AIX Version 2 (RT).
Paul Chamberlain | I do NOT represent IBM. tif at doorstop, sc30661 at ausvm6
512/838-7008 | ...!cs.utexas.edu!ibmchs!auschs!doorstop.austin.ibm.com!tif
More information about the Comp.unix.shell
mailing list