On Sun, 12 Dec 2021 19:15:51 -0600, Scott Cheloha wrote: > cat(1) sizes its I/O buffer according to the st_blksize of the first > file it processes. We don't do this very often in the tree. I'm not > sure if we should trust st_blksize.
It sizes the buffer based on st_blksize of stdout, not the input file. Since st_blksize is the "optimal" blocksize for that device. Since cat only has a single output, the output buffer only needs to be sized once. > It would be simpler to just choose a value that works in practice and > always use it. I prefer it the way it is now. By using st_blksize you get the proper block size regardless of whether output is to a pipe, a file or a tty. I didn't suggest this for tee since it supports multiple output files. - todd
