From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27061 invoked from network); 1 Nov 2006 18:46:36 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.7 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 1 Nov 2006 18:46:36 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 82362 invoked from network); 1 Nov 2006 18:46:24 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 1 Nov 2006 18:46:24 -0000 Received: (qmail 23014 invoked by alias); 1 Nov 2006 18:46:21 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22944 Received: (qmail 23004 invoked from network); 1 Nov 2006 18:46:21 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 1 Nov 2006 18:46:21 -0000 Received: (qmail 82032 invoked from network); 1 Nov 2006 18:46:21 -0000 Received: from cluster-d.mailcontrol.com (217.69.20.190) by a.mx.sunsite.dk with SMTP; 1 Nov 2006 18:46:16 -0000 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly19d.srv.mailcontrol.com (MailControl) with ESMTP id kA1Ik8qB002594 for ; Wed, 1 Nov 2006 18:46:10 GMT Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Wed, 1 Nov 2006 18:46:07 +0000 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.13.7/8.13.4) with ESMTP id kA1Ik7QI022105 for ; Wed, 1 Nov 2006 18:46:07 GMT Received: from csr.com (pws@localhost) by news01.csr.com (8.13.7/8.13.7/Submit) with ESMTP id kA1Ik7tN022102 for ; Wed, 1 Nov 2006 18:46:07 GMT Message-Id: <200611011846.kA1Ik7tN022102@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk Subject: Re: stdout bug? (redirection not honored) In-reply-to: <20061101184128.GA95245@arctic.icelab.net> References: <20061101184128.GA95245@arctic.icelab.net> Comments: In-reply-to "J.D. Laub" message dated "Wed, 01 Nov 2006 11:41:28 -0700." Date: Wed, 01 Nov 2006 18:46:07 +0000 From: Peter Stephenson X-OriginalArrivalTime: 01 Nov 2006 18:46:07.0774 (UTC) FILETIME=[FE055BE0:01C6FDE5] Content-Type: text/plain MIME-Version: 1.0 X-Scanned-By: MailControl A-07-06-70 (www.mailcontrol.com) on 10.68.0.129 "J.D. Laub" wrote: > Is this a bug? No, see below. > % uname -s -r -v -m -p -i -o > Linux 2.4.21-32.0.1.ELsmp #1 SMP Tue May 17 17:52:23 EDT 2005 i686 i686 i386 > GNU/Linux > % echo $ZSH_VERSION > /dev/null | cat # should print nothing, but... > 4.3.2 > > The problem becomes an issue when you have a command that generates > something on both stdout and stderr, and you want to dump the stdout > and page through the stderr: > > % foo 2>&1 > /dev/null | more > > I'm hoping someone says this can be addressed by setting an > option. :-) Yes, indeed. 3.26: Why is my output duplicated with `foo 2>&1 >foo.out | bar'? This is a slightly unexpected effect of the option MULTIOS, which is set by default. Let's look more closely: foo 2>&1 >foo.out | bar What you're probably expecting is that the command `foo' sends its standard output to the pipe and so to the input of the command `bar', while it sends its standard error to the file `foo.out'. What you actually see is that the output is going both to the pipe and into the file. To be more explicit, here's the same example with real commands: % { print output; print error >&2 } 2>&1 >foo.out | sed 's/error/erratic' erratic output % cat foo.out output and you can see `output' appears twice. It becomes clearer what's going on if we write: % print output >foo1.out >foo2.out % cat foo1.out output % cat foo2.out output You might recognise this as a standard feature of zsh, called `multios' and controlled by the option of the same name, whereby output is copied to both files when the redirector appears twice. What's going on in the first example is exactly the same, however the second redirector is disguised as a pipe. So if you want to turn this effect off, you need to unset the option `MULTIOS'. To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php