3 ms·
> read() with size 1 FYI shells do this when reading line-by-line from non-seekable streams (e.g. pipes). It's not really feasible to do buffer I/O when you ha
by oshiar53-0 5y ago
> read() with size 1
FYI shells do this when reading line-by-line from non-seekable streams (e.g. pipes). It's not really feasible to do buffer I/O when you have subprocesses around, and you can't just ungetc(3) into arbitrary file descriptors. A potential performance worth nothing IMO—that is, if you ever do text processing with a bunch of read commands and not sed/awk/whatever like a normal person. Of course this doesn't apply to seekable files, but it still has to rewind back to immediately after the last newline character so there's that.
- vidarh 5y agoYeah, there are occasional acceptable reasons to do this, but they are thankfully rarely what causes an issue. More like e.g. how the MySQL client library used to do this (many years ago; last I checked years ago it was fixed)