From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8217 invoked by alias); 27 Oct 2013 17:01:40 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18061 Received: (qmail 8589 invoked from network); 27 Oct 2013 17:01:35 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <131027100137.ZM4100@torch.brasslantern.com> Date: Sun, 27 Oct 2013 10:01:37 -0700 In-reply-to: <20131027145917.GA5509@localhost.localdomain> Comments: In reply to Han Pingtian "multios doesn't work with 2>&1" (Oct 27, 10:59pm) References: <20131027145917.GA5509@localhost.localdomain> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: multios doesn't work with 2>&1 MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Oct 27, 10:59pm, Han Pingtian wrote: } } According to the zsh guide's "2.5.8 `Go faster' options for power } users", page 44: } } % echo foo 2>&1 >/dev/null | sed 's/foo/bar/' } } should output "bar" if multios has been set. But it outputs nothing Hmm, looks like this has been broken for a LONG time. If I back out workers/20666 (Jan 2005), then this example works again. Note that % print -u2 foo 2>&1 >/dev/null | sed 's/foo/bar/' does print "bar", so the problem is that the original fd 1 is directed to /dev/null while the multio fd created by 2>&1 is is directed to the pipe. You can see the reasoning for this in the "references" thread going back from http://www.zsh.org/mla/workers/2005/msg00026.html The workaround is to either explicitly add the original stdout to the multio: % echo foo 2>&1 >&1 >/dev/null | sed 's/foo/bar/' Or to make sure the multio isn't created until the pipe is seen: % { echo foo 2>&1 } >/dev/null | sed 's/foo/bar/' If there's a way to fix the original complaint (that >&- doesn't really close the descriptor when a multio is involved, so unnecessary multios result) without the above example remaining broken, I may need some help to find it. Otherwise we have to decide whether to revert to the pre-2005 behavior, or document around it.