From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3913 invoked by alias); 2 Oct 2014 04:07:39 -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: 33318 Received: (qmail 3871 invoked from network); 2 Oct 2014 04:07:38 -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: <141001210741.ZM6790@torch.brasslantern.com> Date: Wed, 01 Oct 2014 21:07:41 -0700 In-reply-to: <20141001201705.23ee198d@pws-pc.ntlworld.com> Comments: In reply to Peter Stephenson "Re: PATCH: functions with redirections" (Oct 1, 8:17pm) References: <20140929205236.2eb5e622@pws-pc.ntlworld.com> <20141001201705.23ee198d@pws-pc.ntlworld.com> 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 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. } The main sticking point is where you need to add the wrapper } you have an Eprog, and it's hard to convert that back into the form you } need for adding additional components or glueing bits together --- Yes. This was what I ran into as well. } So I'll simply document around this and be satisfied with the fact that } it is possible to compile an autoload file like } } foo() { echo foo } >&3 } } with or without the zsh kludge 'foo "$@"' stuck at the end. I suspect } compiling existing autoload files is much more common than compiling } functions typed into the shell. Hmm. 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%