From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20236 invoked by alias); 9 Jan 2017 04:17:10 -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: 40316 Received: (qmail 10267 invoked from network); 9 Jan 2017 04:17:10 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.25):SA:0(-0.7/5.0):. Processed in 2.253858 secs); 09 Jan 2017 04:17:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=999ckel5k7Rd21O rcXfeOIx8t5w=; b=wP1LX6xhY1W6tdwHaGpSvVkpnhUl650j+MQaABipBfSZ1TF KrdX23XtZbey3x/+b70dzOxKVC2LlLRGRP+2uDx/y2QXWIbYFyz9xKMhNVzYCBb2 oyGzi7qSRPr1DtZvyFAH30tA0sZhkv3dNxGn8w7uutfuj1CbTAwnVFiXeq8Y= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=999ckel5k7Rd21 OrcXfeOIx8t5w=; b=WzuAWZz/Ew7HPXGCRtYZSCiNp5X1x/qIkKFQ0RQSyrJRZ3 azOqd1kfrqAyTYTyX9GLLkbWlnH6pmuPUR2h2sk1TxOltWywa6gDC7q+NiZgU7IU DS9nGCdfemxuP5OQHUDJJvh0xMCrKovp2MVMyhSSJGh8HrXjFE4W+VBxaXWbE= X-ME-Sender: X-Sasl-enc: Lz9zSfF5jz7kZb4fWM99kLMTFC0TWOvZTEKtqZ5xSyq8 1483934777 Date: Mon, 9 Jan 2017 04:02:58 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: Re: Defining function based on alias Message-ID: <20170109040258.GA8019@fujitsu.shahaf.local2> References: <20170107221659.1b9232da@ntlworld.com> <20170108191922.3d3de59f@ntlworld.com> <170108160921.ZM11340@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <170108160921.ZM11340@torch.brasslantern.com> User-Agent: Mutt/1.5.23 (2014-03-12) Bart Schaefer wrote on Sun, Jan 08, 2017 at 16:09:21 -0800: > On Jan 8, 7:19pm, Peter Stephenson wrote: > } > } I am about to commit the following, which I hope will hope will stop > } people coming to grief with this common confusion. Please say if you > } see any problems. > > OK, here's an unusual case ... > > alias safely:foo='[[ -n $functions[foo] ]] || foo' > > safely:foo() { echo this is foo only if no other foo } > > I hesitate to suggest further convolutions, but maybe an option to the > alias command to "locally" switch on ALIAS_FUNC_DEF if it's actually > *meant* to be used that way? This case doesn't require a new option: alias safely:foo='[[ -n $functions[foo] ]] || function foo' > Probably not very important. > Another case: % alias foo='' % foo() echo hey hey Or less minimally: % setopt NO_multifuncdef % alias foo='' % foo bar () : % which -a foo bar foo: aliased to bar () { : } Should these two behave differently when the new option is set? The first case appeared to be a non-anonymous function definition and the second a multifuncdef, but the alias changed the semantics. As Bart said: probably not very important.