[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [doc] read -t and sockets, devices...
From: |
Stephane Chazelas |
Subject: |
Re: [doc] read -t and sockets, devices... |
Date: |
Sat, 14 Jun 2008 00:31:16 +0100 |
User-agent: |
Mutt/1.5.16 (2007-09-19) |
On Fri, Jun 13, 2008 at 06:52:48PM -0400, Chet Ramey wrote:
[...]
>> Also, it may be good to specify that, if the timeout is
>> reached, bash will consume the input but will not put
>> that consumed input into the variable:
>
> Actually, the bash-4.0 implementation will put the input read into
> the specified variable(s), but will still return failure if the timeout
> is hit.
>
> I think the best way to differentiate is to clear the variable before
> the call, then check the variable afterward. You can treat the read
> as having failed, but still use whatever data was read, if any.
[...]
Thanks, however in the:
sleep 1 | bash -c 'read -t2'
and
sleep 2 | bash -c 'read -t1'
case, that still won't help. The first case is eof, second is
timeout. $REPLY will be empty in both cases, and 1 returned.
What about a different $? (like 2 for timeout)?
--
Stéphane