Why there's no different? EOF means you have nothing to read.

If you put it into a while loop context:

while read -d '' line; do echo "$line"; done < <(printf '1')


give you nothing. There's only one read in this case

There's data to read, but read return non-zero there. it doesn't find
delimiter, does it?

Compare to:

while read -d '' line; do echo "$line"; done < <(printf '1\0')


give you 1. There two read, the first *read* 1, the second reached EOF,
cause the while loop terminated.

On Wed, Feb 24, 2016 at 9:24 PM, Greg Wooledge <wool...@eeg.ccf.org> wrote:

> > > It's the same thing.  "Reached EOF before seeing the delimiter" is the
> > > whole, combined reason.
> >
> > How can we verify it?
> >
> > Stephane Chazelas also have the same opinion with me in his answer
> > http://unix.stackexchange.com/a/265484/38906, that's error came from no
> > delimiter found.
>
> You're confused.  There is no difference between the two things.  They
> are the two sides of the same check.
>
> When read reads from stdin, it will either encounter EOF, or it won't.
> If it encounters EOF, it returns nonzero.  If it doesn't encounter EOF,
> it looks to see if it found the delimiter character.  If so, it returns
> zero.  If not, it continues reading.
>
> That's literally all of the possible outcomes, apart from non-EOF errors.
>

Reply via email to