Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Sep 1997 08:36:19 +0200
From:      j@uriah.heep.sax.de (J Wunsch)
To:        hackers@FreeBSD.ORG
Subject:   Re: Timeout for sh(1) 'read' ??
Message-ID:  <19970928083619.EN11505@uriah.heep.sax.de>
In-Reply-To: <199709280603.PAA04849@word.smith.net.au>; from Mike Smith on Sep 28, 1997 15:33:13 %2B0930
References:  <19970928073430.CC50911@uriah.heep.sax.de> <199709280603.PAA04849@word.smith.net.au>

next in thread | previous in thread | raw e-mail | index | archive | help
As Mike Smith wrote:

> > 	$foo=${foo:-default}
> 
> Hmm.  Actually,  you would get the desired behaviour with 
> 
> val=${default}

Well, sure.  I didn't see this. :) You need to assign a value in the
first place anyway.

> read -t 5 val
> 
> because read won't have had a chance to modify 'val' if it does time 
> out.  So should read return an error if it times out? What does ksh do?

It does:

j@uriah 66% ksh93
$ read -t 5 foo		# and just wait
$ echo $?
1
$ read -t 5 foo
babble
$ echo $?
0
$ exit

-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)



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