From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15419 invoked by alias); 30 Sep 2014 04:51:40 -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: 33291 Received: (qmail 26601 invoked from network); 30 Sep 2014 04:51:36 -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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=SqshkLNheFYngUIxlBsBj92EBoJ7/CHiMb6hVjc8CNE=; b=x2s5E+yeT6RcAsccglQRtNLUh0qQimC8dRoJ1EXQYDfm0OAIftyc8R3U2dvsnYOVLi P6E6HnOpjWzgvNfiy62jWEdacRYNkD5ZXjhA1TNSNTX5z6eERujqOxt/YZh/KEmkluLf E7suGNgiYN6pB0rAwUtR4YNp6MY2EeAKwGMyTxPZ0E8N/+HIjlfqA26ZYAyvLP/Zb6R8 lV+0KbymuNR+OoRFy8Md/zEETEmeKChnqckO6WxZDAIrfjMDw5mEf1OzAmCLAVOA92JF kBZXBn2M/cnA7YPQFhFwP/5FgYmxveDIYN7gJtTU0QOxGaEuZvNSBYBSzXA2egf0JF5Y ZFEw== MIME-Version: 1.0 X-Received: by 10.50.87.99 with SMTP id w3mr3903755igz.4.1412052691752; Mon, 29 Sep 2014 21:51:31 -0700 (PDT) In-Reply-To: References: <20140929205236.2eb5e622@pws-pc.ntlworld.com> Date: Tue, 30 Sep 2014 06:51:31 +0200 Message-ID: Subject: Re: PATCH: functions with redirections From: Mikael Magnusson To: Bart Schaefer Cc: Zsh hackers list Content-Type: text/plain; charset=UTF-8 On 29 September 2014 23:37, Bart Schaefer wrote: > On Sep 29, 2014 1:53 PM, "Bart Schaefer" wrote: >> >> >> On Sep 29, 2014 12:52 PM, "Peter Stephenson" > wrote: >> > >> > I haven't yet looked at dump files. That's partly becuase I don't >> > understand them and partly because I don't use them. Any hints would be >> > great. >> >> By dump files do you mean zcompile? >> I fear I'm not of much help there. > > A thought: > > My first idea when this came up was to alter the wordcode for functions > with redirections to explicitly add the implicit set of braces, e.g., > > foo () { echo foo } >&3 > > becomes > > foo () { { echo foo } >&3 } > > Then it would not be necessary to mess with printing/dumping etc. of the > definition, or invent a new place to store the redirections. Yeah, output > of "functions" et al. becomes a little less faithful but so what? > > Sadly I never managed to make that work, but maybe the concept is helpful > for dump file creation. I noticed that the contents of $functions[foo] in the former case completely omits the redirection as it is currently. An argument for turning the syntax into the latter is that you could claim it wasn't a function definition of the form foo() { ... } in the first place, but a foo() ... definition, where ... happens to be { xyz } > &3 which is also a valid single statement command, printing the function in a normalized form would then tack on the outer braces as usual. I don't know if this would hold up in court though. -- Mikael Magnusson