From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1923 invoked by alias); 2 Oct 2014 15:54:34 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 33327 Received: (qmail 14727 invoked from network); 2 Oct 2014 15:54:21 -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: <141002085427.ZM12149@torch.brasslantern.com> Date: Thu, 02 Oct 2014 08:54:27 -0700 In-reply-to: <20141002093509.789ff912@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "Re: PATCH: functions with redirections" (Oct 2, 9:35am) References: <20140929205236.2eb5e622@pws-pc.ntlworld.com> <20141001201705.23ee198d@pws-pc.ntlworld.com> <141001210741.ZM6790@torch.brasslantern.com> <20141002093509.789ff912@pwslap01u.europe.root.pri> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh hackers list Subject: Re: PATCH: functions with redirections MIME-version: 1.0 Content-type: text/plain; charset=us-ascii (Sorry for the extensive context for short responses.) On Oct 2, 9:35am, Peter Stephenson wrote: } } On Wed, 01 Oct 2014 21:07:41 -0700 } Bart Schaefer wrote: } > On Oct 1, 8:17pm, Peter Stephenson wrote: } > } } > } On Mon, 29 Sep 2014 14:37:35 -0700 } > } Bart Schaefer wrote: } > } > } > } > foo () { { echo foo } >&3 } } > } > } +function is executed. Any variables in the redirection are expanded } > } +at the point the function is executed, but outside the function scope. } } It doesn't make any obvious practical difference simply to expanding } variables given that no variables appear in the function before the } redirection is applied. It makes a practical difference if $argv or its aliases are mentioned, or for special parameters like funcstack and zsh_eval_context. } > torch% cat /tmp/foo } > foo() { echo foo } >&3 } > torch% zcompile -k /tmp/foo } > torch% autoload foo } > torch% FPATH=/tmp foo } > foo } > } > Oops, the redirection didn't get applied. } } Not sure how that could happen --- there must be some kludge to run the } function the first time. I guess this is specific to ksh style --- } there may be something funny with the EF_RUN flag. loadautofn() does a direct call to execode() in some cases but not in others. That or something like it is probably bypassing the redirect handling.