zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Aliasing assignment-ish words (aliases[x=y]=z)
Date: Sun, 10 Jan 2016 11:19:43 -0800	[thread overview]
Message-ID: <160110111943.ZM864@torch.brasslantern.com> (raw)
In-Reply-To: <20160110003757.GA18461@tarsus.local2>

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.

} 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.

That still doesn't help with the assignment-syntax conflict.


  reply	other threads:[~2016-01-10 19:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-01  0:37 Daniel Shahaf
2016-01-10 19:19 ` Bart Schaefer [this message]
2016-01-10 19:50   ` Daniel Shahaf
2016-01-12  7:44     ` Bart Schaefer
2016-01-13  0:57       ` Daniel Shahaf
2016-01-13  0:58       ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=160110111943.ZM864@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).