From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5032 invoked by alias); 2 Oct 2014 08:35:19 -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: 33322 Received: (qmail 12874 invoked from network); 2 Oct 2014 08:35:14 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f4-b7f156d0000063c7-51-542d0e3e7c0b Date: Thu, 02 Oct 2014 09:35:09 +0100 From: Peter Stephenson To: Zsh hackers list Subject: Re: PATCH: functions with redirections Message-id: <20141002093509.789ff912@pwslap01u.europe.root.pri> In-reply-to: <141001210741.ZM6790@torch.brasslantern.com> References: <20140929205236.2eb5e622@pws-pc.ntlworld.com> <20141001201705.23ee198d@pws-pc.ntlworld.com> <141001210741.ZM6790@torch.brasslantern.com> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjluLIzCtJLcpLzFFi42I5/e/4NV07Pt0Qgynr2SwONj9kcmD0WHXw A1MAYxSXTUpqTmZZapG+XQJXxrZv01kKXvJU3Jg2gb2B8QFnFyMnh4SAicS69mdMELaYxIV7 69m6GLk4hASWMkrs2HmLHcJZziSxasFzsCoWAVWJS/c3sIPYbAKGElM3zWYEsUUEtCR2nDwJ ViMsoC/xZ+NJsDivgL3EjhWr2EBsTgFLidebupkghi5jkjj9dAYLSIIfqOHq309QZ9hLzLxy BqpZUOLH5HtgNcxACzZva2KFsOUlNq95yzyBUWAWkrJZSMpmISlbwMi8ilE0tTS5oDgpPddQ rzgxt7g0L10vOT93EyMkDL/sYFx8zOoQowAHoxIPb0aDTogQa2JZcWXuIUYJDmYlEd5Vk4FC vCmJlVWpRfnxRaU5qcWHGJk4OKUaGMOmPfn60HbvU7PuRZ+8U5bc1GPaEB7A0nFbaD2HY+cv 5SCuF7rvrSKLvxZMW2TE9dynPlbohUitR8te0aZv+3nTnJz2F3OZ5yn9bLx2dsk6uc4rf/1S My5tjH68Y27mUlljId9Dd4w7kn229DKlPplaepX7483Lq/8UafpERavdi1pYXbnDWYmlOCPR UIu5qDgRAKFyxvIhAgAA On Wed, 01 Oct 2014 21:07:41 -0700 Bart Schaefer wrote: > On Oct 1, 8:17pm, Peter Stephenson wrote: > } Subject: Re: PATCH: functions with redirections > } > } On Mon, 29 Sep 2014 14:37:35 -0700 > } Bart Schaefer wrote: > } > > } > foo () { echo foo } >&3 > } > > } > becomes > } > > } > foo () { { echo foo } >&3 } > } > } This appears to be about the only way I could even conceivably get this > } to work --- otherwise it means reengineering multiple different ways of > } constructing and reading a dump file --- but even this appears too > } difficult. > > It's also apparently wrong, if this ... > > } +function is executed. Any variables in the redirection are expanded > } +at the point the function is executed, but outside the function scope. > > ... is actually the way it's supposed to work. 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. > 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. But it does once the function > is loaded and then called: > > torch% functions foo > foo () { > echo foo > } >&3 > torch% foo > zsh: 3: bad file descriptor > torch% 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. pws