[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ``read -N n -t timeout'' saves partial input only when EOF is seen?
From: |
L A Walsh |
Subject: |
Re: ``read -N n -t timeout'' saves partial input only when EOF is seen? |
Date: |
Thu, 24 Nov 2016 15:05:19 -0800 |
User-agent: |
Thunderbird |
isabella parakiss wrote:
that's not true https://gist.github.com/fa4efd90376ff2714901e4429fdee734
read successfully reads the data, but then it's discarded by bash
----
It's discarded by bash because the read doesn't read 10
characters within the time limit. If you use -N 5, you get
your output. "-t" says it will timeout and return failure if a
specified number of characters is not read within timeout period.
If timeout is exceeded, then return status is > 128:
bash -c '( printf 12345; sleep 2 ) | ( read -t 1 -N 10 v; echo "s=$?,
<$v>" )'
s=142, <>
(status is > 128)