From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11699 invoked from network); 5 Nov 2008 21:21:01 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 5 Nov 2008 21:21:01 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 88939 invoked from network); 5 Nov 2008 21:20:55 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 5 Nov 2008 21:20:55 -0000 Received: (qmail 28382 invoked by alias); 5 Nov 2008 21:20:49 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26010 Received: (qmail 28365 invoked from network); 5 Nov 2008 21:20:48 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 5 Nov 2008 21:20:48 -0000 Received: from mail.o2.co.uk (yoda.london.02.net [82.132.130.151]) by bifrost.dotsrc.org (Postfix) with ESMTP id 13E3280308BE for ; Wed, 5 Nov 2008 22:20:46 +0100 (CET) Received: from sc.homeunix.net (78.105.216.138) by mail.o2.co.uk (8.0.013.3) (authenticated as stephane.chazelas) id 491095A300531945 for zsh-workers@sunsite.dk; Wed, 5 Nov 2008 21:20:41 +0000 Received: from chazelas by sc.homeunix.net with local (Exim 4.69) (envelope-from ) id 1Kxpno-0002xy-Ez for zsh-workers@sunsite.dk; Wed, 05 Nov 2008 21:20:36 +0000 Date: Wed, 5 Nov 2008 21:20:36 +0000 From: Stephane Chazelas To: Zsh hackers list Subject: f() { ...; } > file Message-ID: <20081105212036.GA4698@sc.homeunix.net> Mail-Followup-To: Zsh hackers list MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.5.16 (2007-09-19) X-Virus-Scanned: ClamAV 0.92.1/8576/Wed Nov 5 19:28:48 2008 on bifrost X-Virus-Status: Clean Hiya, $ bash -c 'foo() { echo a >&3; } 3>&1; foo' a $ ksh -c 'foo() { echo a >&3; } 3>&1; foo' a $ zsh -c 'foo() { echo a >&3; } 3>&1; foo' foo: 3: bad file descriptor $ ARGV0=sh zsh -c 'foo() { command echo a >&3; } 3>&1; foo' foo: 3: bad file descriptor It looks like zsh evaluates the redirection at the time the function is defined rather than when it is called. It's OK when declaring the function as foo() echo a > file or foo() (echo a) > file instead of foo() { echo a; } > file -- Stéphane