Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Sep 1997 11:23:03 +0930
From:      Greg Lehey <grog@lemis.com>
To:        Joerg Wunsch <joerg_wunsch@uriah.heep.sax.de>
Cc:        hackers@FreeBSD.ORG, Mike Smith <mike@smith.net.au>
Subject:   Re: Timeout for sh(1) 'read' ??
Message-ID:  <19970928112303.32188@lemis.com>
In-Reply-To: <19970927163558.WP09379@uriah.heep.sax.de>; from J Wunsch on Sat, Sep 27, 1997 at 04:35:58PM %2B0200
References:  <199709260748.RAA00456@word.smith.net.au> <19970927163558.WP09379@uriah.heep.sax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19970928112303.32188>