Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Aliasing assignment-ish words (aliases[x=y]=z)
- X-seq: zsh-workers 37548
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Aliasing assignment-ish words (aliases[x=y]=z)
- Date: Sun, 10 Jan 2016 19:50:30 +0000
- Cc: zsh-workers@xxxxxxx
- 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=
- In-reply-to: <160110111943.ZM864@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20160110003757.GA18461@tarsus.local2> <160110111943.ZM864@torch.brasslantern.com>
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author