I guess what happens is this:
$ read line < $f
opens the FIFO for reading, reads one line, then closes the FIFO. Once the reader closes the FIFO on its side, the writer (seq 5 > $f
) also closes. When you open the FIFO next time nobody writes to it at that point, so the read
blocks.
With the while
the FIFO is open for reading until the while
command finishes, allowing the writer to send more lines to the FIFO.
You can use lsof -p $$
to verify what files are (not) open at each point.