From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9475 invoked by alias); 10 Jan 2016 19:50:35 -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: 37548 Received: (qmail 10937 invoked from network); 10 Jan 2016 19:50:34 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=V/PJekaNuIW8EDEA 38OxwN1dbMk=; b=FbxJkc/wF7YUe30Z1vXE1ux4HiGNB1ctJNTB4enIwfd4BmsJ 3VJmxVeflCyqv3d0Whj8aXOB6PjlSzcBsjj3+6S37VmHIMZnYI4rAIjvhwPHeTuF 9EnFb2QgP7kjitWtU09KO7OvZPf+zDuT+3tXvcYkrnsk/o50PfLYkwflO+k= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=V/PJekaNuIW8EDE A38OxwN1dbMk=; b=cF2tMVrVuZSrvXYhSk24GAR2uIWujZNRtKNtAF88qo8/0rj bYos9xcJjRx2pNXbCXheo6PdLXfA0dBhUwywcucpK+gQiewoRpjqw912dy+zv06O 2aa2nAdCqMdtjzRtaozTCGdsfvVRc1rXo0ex8bjBwNPcXJteHXnEX5DbGJds= X-Sasl-enc: JtnuBvUqKrYZ9K2RDfgrCThTjYnivzPm6qThVKW2kb+i 1452455432 Date: Sun, 10 Jan 2016 19:50:30 +0000 From: Daniel Shahaf To: Bart Schaefer Cc: zsh-workers@zsh.org Subject: Re: Aliasing assignment-ish words (aliases[x=y]=z) Message-ID: <20160110195030.GB1997@tarsus.local2> References: <20160110003757.GA18461@tarsus.local2> <160110111943.ZM864@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <160110111943.ZM864@torch.brasslantern.com> User-Agent: Mutt/1.5.21 (2010-09-15) Bart Schaefer wrote on Sun, Jan 10, 2016 at 11:19:43 -0800: > On Jan 1, 12:37am, Daniel Shahaf wrote: > } Subject: Aliasing assignment-ish words (aliases[x=y]=z) > } > } 2 % aliases[x=y]=z > } 9 % x=y > } > } Shouldn't line 9 have interpreted the word 'x=y' as an alias? > > No; alias expansion operates on shell words, and in that position > on the command line "x" "=" and "y" are separate words because of > assignment syntax rules. The new treatment of "typeset" as keyword > extends this to global aliases and "typeset x=y". > > There's more to it than this because "=" and "y" are not subject to > global alias expansion when they appear in "x=y" but that's the basic > premise. > > } Or perhaps line 2 should have signaled an error. > > It's long-standing practice that you can create alias table entries for > things that it's not actually possible to later interpret as aliases. > This is especially true when assigning to the parameter as you did. > > Basically in this case the rule is that if you break it you get to keep > the pieces. > Fair enough. > } Also, the 'alias -L' output for that alias won't work as the code > } producing the output intended. > > There is no correct output possible in this instance, the alias command > provides no way to escape the equal sign. I don't see any reasonable > alternative except to add a csh-style alias command where the word and > its expansion can be separate arguments. > I thought we might want to have 'alias -L' handle LHSes with '=' in them specially: omit them from the output with a warning, or maybe fail hard with no output at all. It'd be slightly friendlier than emitting wrong output (that may override other aliases) letting the user keep both pieces. For what it's worth, the real-world use-case behind this thread is a z-sy-h user whose zshrc has an alias «aliases[=]='noglob ='» and a function literally named '='. (That alias works as expected, as does «aliases[=ls]='…'» even if EQUALS is set.) Thanks, Daniel > That still doesn't help with the assignment-syntax conflict.