Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!warwick!covpoly!csx040 From: csx040@cck.cov.ac.uk (Alan Chantler (CS)) Newsgroups: comp.unix.shell Subject: Re: Clearing the input buffer before a read. Message-ID: <1990Nov30.092653.14670@cck.cov.ac.uk> Date: 30 Nov 90 09:26:53 GMT References: <1990Nov26.001425.15563@massey.ac.nz> Organization: Coventry Polytechnic, Coventry, UK Lines: 30 In article <1990Nov26.001425.15563@massey.ac.nz> K.Spagnolo@massey.ac.nz (Ken Spagnolo) writes: >I have an sh script that asks the user a question and reads >the answer into a variable in the usual method. I want to >be able to flush the input buffer just before the read so >that any slips or double key bounces get ignored, rather than >used as the answer. I realize this disables type ahead, but >I can live with that. Anyone know how to do this? OK This is not quite the answer that you seek, but it may help. Whenever I want a script to read into a variable (say 'fubar') then I use: read fubar junk This will capture any 'extras' into 'junk', which I ignore. Of course it doesn't work unless there is whitespace after legitimate input, but it can be extended for any number of inputs on a line: read x y z junk etc. -- AlanC@coventry.ac.uk | Post: Coventry Polytechnic JANET: AlanC@uk.ac.coventry | Priory Street INET : AlanC%coventry.ac.uk@nsfnet-relay.ac.uk | Coventry, UK Phone: +44 203 838332 | CV1 5FB