Advanced shell scripting question :-)

Bob Bell bobbell at zk3.dec.com
Thu Sep 5 13:03:13 EDT 2002


On Thu, Sep 05, 2002 at 10:04:17AM -0400, Steven W. Orr <steveo at syslang.net> wrote:
> What I currently have that gets me closer is as follows:
> 
> p  2>&1 2> >(tee ERR)  | tee BOTH

    BTW, I don't know what the '2>&1' is for.  I get the same behavior
without it.

> The problem is this: I expect that when data is written to a pipe, that 
> the the order is preserved. Using this construct, the order is *not* 
> preserved. So on a p that produces many kilobytes of spew, I get big 
> chunks in the BOTH file which are from each seperate channel.

    I think what you are see is that p is writing to the pipe to "tee
BOTH", and "tee ERR" is writing to the pipe to "tee BOTH".  Due to
scheduling between the two processes, buffering, etc., ordering is not
guaranteed.

-- 
Bob Bell <bobbell at zk3.dec.com>
-------------------------------------------------------------------------
 "Q. I find this a nice feature but it is not according to the
     documentation.  Or is it a BUG?
  A. Let's call it an accidental feature. :-)"
   -- Larry Wall, creator of the Perl programming language



More information about the gnhlug-discuss mailing list