From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5146 invoked from network); 3 Oct 2000 16:43:32 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 3 Oct 2000 16:43:32 -0000 Received: (qmail 14272 invoked by alias); 3 Oct 2000 16:42:58 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12871 Received: (qmail 14265 invoked from network); 3 Oct 2000 16:42:56 -0000 From: "Bart Schaefer" Message-Id: <1001003164236.ZM21637@candle.brasslantern.com> Date: Tue, 3 Oct 2000 16:42:36 +0000 X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.auc.dk Subject: Redirection with multiple coprocs MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii About a year ago, I wrote: } coproc tr a-z A-Z } exec 5>&p ;: descriptor 5 is now the input of tr } exec 6<&p ;: descriptor 6 is now the output of tr } coproc sed s/DOG/CAT/ 5>&- } exec 7>&p ;: descriptor 7 is now the input of sed } exec 8<&p ;: descriptor 8 is now the output of sed } coproc exit ;: close p } cat <&6 >&7 5>&- 7>&- & : tr is now connected to sed } exec 6<&- 7>&- ;: close shell copies of descriptors This can of course be shortened as: coproc tr a-z A-Z exec 5>&p 6<&p coproc sed s/DOG/CAT/ <&6 5>&- exec 6<&- 8<&p coproc exit It seems to me that the following should be an even shorter way (or at least, using fewer descriptors): coproc tr a-z A-Z exec 5>&p coproc sed s/DOG/CAT/ <&p exec 8<&p coproc exit But it doesn't work, because the old coproc descriptors are closed before the redirection to the new coproc is processed, so sed gets a closed stdin. How does ksh handle redirecting the coproc descriptors to a new coproc? -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net