Use of tee(2) to speedup reading from pipes

Sam James <[email protected]>
Newsgroups gmane.comp.shells.bash.bugs
Organization Gentoo
Message-ID <[email protected]>
Hi,

bash currently probes a pipe w/ lseek, sees it isn't seekable, and then
falls back to reading 1 byte at a time.

A few years ago, dash adopted [0] use of tee(2) to peek at the contents
of stdin and read the amount of bytes left instead rather than 1.

Could this be considered for bash too? My interest in this is partly
speed but also to avoid a lot of noisy read()s of size 1 which can
obfuscate actual problems and can be hard to decipher (as you have to
concatenate the values from each line mentally).

[0] 44b15ea09a9ee5872cf477e4ffc6b42ef37d1e46 with some followups
    afterwards in 1713d1d6592f09f23b5abfb4562cbe5a7615fb1a,
    41457be81fa7b45af9d9ca402454fee0e555620f,
    and 0679594e72403f4a6d7890e627b75816f6feb0d5.

thanks,
sam
signature.asc (application/pgp-signature, 418 B)
-----BEGIN PGP SIGNATURE-----

iQEBBAEWCgCpFiEEJaa7iN2bdkxrVUHCc4QJ9SDfkZAFAmqLeCcbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwyXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25z
Lm9wZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQyNUE2QkI4OEREOUI3NjRDNkI1NTQx
QzI3Mzg0MDlGNTIwREY5MTkwDxxzYW1AZ2VudG9vLm9yZwAKCRBzhAn1IN+RkIYN
AQDbdWPIJaC5OYwu3GWFmhyoPRTrUAWBcqq1b+BFNQ5JbgEAz4Y830AX4K4TccIg
RrRtIkkAa1+agAc7hxgXKsJhcgA=
=AovI
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.