From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13243 invoked from network); 9 Jan 2005 20:33:38 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 9 Jan 2005 20:33:38 -0000 Received: (qmail 50854 invoked from network); 9 Jan 2005 20:33:32 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 9 Jan 2005 20:33:32 -0000 Received: (qmail 2143 invoked by alias); 9 Jan 2005 20:33:29 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20659 Received: (qmail 2129 invoked from network); 9 Jan 2005 20:33:28 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 9 Jan 2005 20:33:28 -0000 Received: (qmail 50485 invoked from network); 9 Jan 2005 20:32:29 -0000 Received: from out003pub.verizon.net (HELO out003.verizon.net) (206.46.170.103) by a.mx.sunsite.dk with SMTP; 9 Jan 2005 20:32:25 -0000 Received: from candle.brasslantern.com ([4.11.10.129]) by out003.verizon.net (InterMail vM.5.01.06.06 201-253-122-130-106-20030910) with ESMTP id <20050109203223.QWHB1106.out003.verizon.net@candle.brasslantern.com> for ; Sun, 9 Jan 2005 14:32:23 -0600 Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id j09KWJWF022782 for ; Sun, 9 Jan 2005 12:32:19 -0800 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id j09KWIY1022781 for zsh-workers@sunsite.dk; Sun, 9 Jan 2005 12:32:19 -0800 From: Bart Schaefer Message-Id: <1050109203218.ZM22780@candle.brasslantern.com> Date: Sun, 9 Jan 2005 20:32:18 +0000 In-Reply-To: <20050109164753.GA4246@sc> Comments: In reply to Stephane Chazelas "multios and unnecessary processes" (Jan 9, 4:47pm) References: <20050109164753.GA4246@sc> X-Mailer: Z-Mail (5.0.0 30July97) To: Zsh hackers list Subject: Re: multios and unnecessary processes MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Authentication-Info: Submitted using SMTP AUTH at out003.verizon.net from [4.11.10.129] at Sun, 9 Jan 2005 14:32:20 -0600 X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: * X-Spam-Status: No, hits=1.6 required=6.0 tests=RCVD_IN_NJABL,RCVD_IN_SORBS autolearn=no version=2.63 X-Spam-Hits: 1.6 On Jan 9, 4:47pm, Stephane Chazelas wrote: } Subject: multios and unnecessary processes } } zsh -c 'lsof -ag $$ -d0-2,10-15 >&2 >&- >&2' } } and } } zsh -c 'lsof -ag $$ -d0-2,10-15 >&2' } } To work the same. Interesting. For me, they *do* work the same *if* the command is run from the shell prompt rather than from "zsh -c". In fact, I can only reproduce your results if I use a non-interactive shell. If I put those two commands in files and execute the files with "zsh -if" I get (in both cases): OMMAND PID PGRP USER FD TYPE DEVICE SIZE NODE NAME zsh 22683 22683 schaefer 0u CHR 136,8 10 /dev/pts/8 zsh 22683 22683 schaefer 1u CHR 136,8 10 /dev/pts/8 zsh 22683 22683 schaefer 2u CHR 136,8 10 /dev/pts/8 zsh 22683 22683 schaefer 10r REG 3,1 36 159782 /tmp/lsof1 zsh 22683 22683 schaefer 11u CHR 136,8 10 /dev/pts/8 But if I leave off the -i I get the extra pipe descriptors in the first case. I don't know offhand why multios would behave differently when the shell is interactive. } I came accross this while trying to make some code independant } of the multios setting (hence the >&- to cancel the teed } redirection). I'm a little puzzled by that statement, because in your second example there is no teed redirection. It's only the doubled >&2 that creates a teed redirection in the first place. The right way to write multios-independent code is to wrap things in curly braces, e.g.: { lsof -ag $$ -d0-2,10-15 >&2 } >&2 } I'm not too sure it's a good idea to make multios the default. If I had been in Paul Falstad's place 15 years or so ago, I'd have thought about making the default value of multios follow the the initial value of interactive; that is, having it on for interactive shells unless explicitly turned off, and the reverse for non-interactive shells. Maybe he did think about it, but that's not what he decided.