Path: utzoo!attcan!telly!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!cs.utexas.edu!romp!auschs!awdprime!doorstop.austin.ibm.com!tif From: tif@doorstop.austin.ibm.com (Paul Chamberlain) Newsgroups: comp.unix.shell Subject: Re: Clearing the input buffer before a read. Message-ID: <4328@awdprime.UUCP> Date: 26 Nov 90 16:36:04 GMT References: <1990Nov26.001425.15563@massey.ac.nz> Sender: news@awdprime.UUCP Reply-To: tif@doorstop.austin.ibm.com (Paul Chamberlain) Organization: IBM AWD, Austin, TX Lines: 17 Summary: Expires: Sender: Followup-To: Keywords: In article <1990Nov26.001425.15563@massey.ac.nz> K.Spagnolo@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@doorstop, sc30661 at ausvm6 512/838-7008 | ...!cs.utexas.edu!ibmchs!auschs!doorstop.austin.ibm.com!tif