-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to [EMAIL PROTECTED] on 9/28/2006 11:16 AM: > On Thu, Sep 28, 2006 at 09:12:47PM +0600, [EMAIL PROTECTED] wrote: > [...] >> Description: >> When Process substitution is used, BASH >> reads from such descriptor by one bytes!! > > Of course it does. A shell is a shell, it's a command that runs > other commands. > > So, it's a perfectly normal behavior. That's rather the > optimisation that is not normal (in the sense that it reads more > than what you may expect it to).
Not only is it normal, it is required by POSIX: "When the shell is using standard input and it invokes a command that also uses standard input, the shell shall ensure that the standard input file pointer points directly after the command it has read when the command begins execution. It shall not read ahead in such a manner that any characters intended to be read by the invoked command are consumed by the shell (whether interpreted by the shell or not) or that characters that are not read by the invoked command are not seen by the shell." http://www.opengroup.org/onlinepubs/009695399/utilities/sh.html For reference, for most apps, POSIX states that on non-seekable file descriptors, the position of the file pointer is indeterminate when handing off to another process, in order to allow apps to read a buffer at a time from the pipe, irretrievably losing data if it doesn't consume it all. But this is unacceptable for a shell. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFHJWt84KuGfSFAYARAgoNAKDFOBPp72PC+jMWNTFnsDU5UdFcLwCggboJ XjgcfV4o0G5xFAKxLBtNW+o= =BKda -----END PGP SIGNATURE----- _______________________________________________ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash