From owner-freebsd-hackers Sat Sep 27 18:53:34 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id SAA26687 for hackers-outgoing; Sat, 27 Sep 1997 18:53:34 -0700 (PDT) Received: from freebie.lemis.com (gregl1.lnk.telstra.net [139.130.136.133]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id SAA26681 for ; Sat, 27 Sep 1997 18:53:29 -0700 (PDT) Received: (from grog@localhost) by freebie.lemis.com (8.8.7/8.8.5) id LAA05398; Sun, 28 Sep 1997 11:23:03 +0930 (CST) Message-ID: <19970928112303.32188@lemis.com> Date: Sun, 28 Sep 1997 11:23:03 +0930 From: Greg Lehey To: Joerg Wunsch Cc: hackers@FreeBSD.ORG, Mike Smith Subject: Re: Timeout for sh(1) 'read' ?? References: <199709260748.RAA00456@word.smith.net.au> <19970927163558.WP09379@uriah.heep.sax.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.81e In-Reply-To: <19970927163558.WP09379@uriah.heep.sax.de>; from J Wunsch on Sat, Sep 27, 1997 at 04:35:58PM +0200 Organisation: LEMIS, PO Box 460, Echunga SA 5153, Australia Phone: +61-8-8388-8250 Fax: +61-8-8388-8250 Mobile: +61-41-739-7062 WWW-Home-Page: http://www.lemis.com/~grog Fight-Spam-Now: http://www.cauce.org Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk On Sat, Sep 27, 1997 at 04:35:58PM +0200, J Wunsch wrote: > As Mike Smith wrote: > >> Hiho folks, a question for the sh(1) studs amongst you : >> >> - I want to prompt for input using 'read', and have the read return in >> some fashion after a timeout. > > A quick search for the word `timeout' in the ksh93 man page unveils: > > TMOUT If set to a value greater than zero, TMOUT > will be the default timeout value for the > read built-in command. The select compound > command terminates after TMOUT seconds when > input is from a terminal. Otherwise, the > shell will terminate if a line is not > entered within the prescribed number of sec- > onds while reading from a terminal. (Note > that the shell can be compiled with a maxi- > mum bound for this value which cannot be > exceeded.) > > and: > > read [ -Aprs ] [ -d delim] [ -t timeout] [ -u > unit] [ vname?prompt ] [ vname ... ] > The shell input mechanism. One line is read and is > broken up into fields using the characters in IFS > as separators. [...] > > Posix doesn't seem to have any opinion for this, so it looks like just > creeping featurism on ksh's side. (Posix only mentions option -r.) pdksh and bash both use this variable just for command line prompts. Try this: bash$ TMOUT=5 bash$ (wait 5 seconds) Then bash dies on you. It doesn't work for what Mike's looking for. Greg