From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 497 invoked from network); 10 Feb 2003 04:44:29 -0000 Received: from ns2.primenet.com.au (HELO primenet.com.au) (@203.24.36.3) by ns1.primenet.com.au with SMTP; 10 Feb 2003 04:44:29 -0000 Received: (qmail 15426 invoked from network); 10 Feb 2003 04:44:27 -0000 Received: from sunsite.dk (130.225.247.90) by proxy.melb.primenet.com.au with SMTP; 10 Feb 2003 04:44:27 -0000 Received: (qmail 7381 invoked by alias); 10 Feb 2003 04:43:17 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18214 Received: (qmail 7368 invoked from network); 10 Feb 2003 04:43:15 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 10 Feb 2003 04:43:15 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [204.127.198.38] by sunsite.dk (MessageWall 1.0.8) with SMTP; 10 Feb 2003 4:43:11 -0000 Received: from madstop.pimlott.net (h00a0cc5ad757.ne.client2.attbi.com[65.96.178.14]) by rwcrmhc51.attbi.com (rwcrmhc51) with ESMTP id <20030210044312051007cj6le>; Mon, 10 Feb 2003 04:43:12 +0000 Received: from andrew by madstop.pimlott.net with local (Exim 3.35 #1 (Debian)) id 18i5Wm-0001JZ-00; Sun, 09 Feb 2003 23:26:44 -0500 Date: Sun, 9 Feb 2003 23:26:44 -0500 To: zsh-workers@sunsite.dk Subject: overeager multios Message-ID: <20030210042644.GT27419@pimlott.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.28i From: Andrew Pimlott I just spent several minutes trying to understand a behavior that turned out to be caused by unexpected triggering of multios. A simple example is echo hello 3>&1 >&2 | cat which prints "hello" twice, instead of once as in bash. (In reality, "echo hello" would be a program that writes to both fds 1 and 3.) I think multios is overeager here, as this is a standard shell idiom, and the only way I know of to achieve this effect. A fix would be to ignore (for multios purposes) previous opens when a fd is duped. the shell would process the above as follows. 1. fd 1 will be opened to the pipe. Push that open onto the multios stack for fd 1. 2. fd 1 will be duped to fd 3. Clear the multios stack. 3. fd 2 will be duped to fd 1. Push that open onto the multios stack. 4 fd 1 has only one entry in its multios stack, so don't trigger multios. This will ensure that multios only triggers on a command line that has no useful meaning in sh. I know I can turn off multios, but I think we can have the best of both with the above algorithm. I am using the zsh 4.0.6-13 package on Debian GNU/Linux. Andrew PS. Please Cc: me as I am not subscribed.