* Keyword Aliasing Behaviour
@ 2006-03-26 13:22 Sean B. Palmer
2006-03-26 18:54 ` Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: Sean B. Palmer @ 2006-03-26 13:22 UTC (permalink / raw)
To: zsh-users
Using zsh 4.2.6, I note that keywords can be aliased. For example:
alias in='test'
But then this gets expanded when the "in" keyword is used in a case:
$ case $HOME in *) :;; esac
zsh: parse error near `test'
I asked the #zsh IRC channel on Freenode, and a member there thought
it sounded like a bug and directed me to this mailing list. Can anyone
confirm that this is a bug, or is it a feature? If it's a bug, is it
fixed in a later version? If a feature, what is the rationale for it?
I notice that man zshall states that unless alias is provided with a
-g flag, making the alias global, the alias will only be expanded in a
command position. Since the "in" keyword in a case statement is not in
a command position, the behaviour I'm seeing appears to be erroneous.
The case $var { ... } syntax was suggested to me on #zsh, and is
useful but I probably shouldn't be rebinding keywords anyway.
Nevertheless, this was surprising behaviour.
Thanks,
--
Sean B. Palmer, http://inamidst.com/sbp/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Keyword Aliasing Behaviour
2006-03-26 13:22 Keyword Aliasing Behaviour Sean B. Palmer
@ 2006-03-26 18:54 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2006-03-26 18:54 UTC (permalink / raw)
To: Sean B. Palmer, zsh-users
"Sean B. Palmer" wrote:
> Using zsh 4.2.6, I note that keywords can be aliased. For example:
>
> alias in='test'
>
> But then this gets expanded when the "in" keyword is used in a case:
>
> $ case $HOME in *) :;; esac
> zsh: parse error near `test'
This was certainly considered an error in the case of "for X in", so the
behaviour is inconsistent. This fixes the case of "case".
Index: Src/parse.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/parse.c,v
retrieving revision 1.52
diff -u -r1.52 parse.c
--- Src/parse.c 7 Mar 2006 21:31:22 -0000 1.52
+++ Src/parse.c 26 Mar 2006 18:52:11 -0000
@@ -1023,6 +1023,7 @@
par_case(int *complex)
{
int oecused = ecused, brflag, p, pp, n = 1, type;
+ int ona, onc;
p = ecadd(0);
@@ -1033,14 +1034,23 @@
ecstr(tokstr);
incmdpos = 1;
+ ona = noaliases;
+ onc = nocorrect;
+ noaliases = nocorrect = 1;
yylex();
while (tok == SEPER)
yylex();
if (!(tok == STRING && !strcmp(tokstr, "in")) && tok != INBRACE)
+ {
+ noaliases = ona;
+ nocorrect = onc;
YYERRORV(oecused);
+ }
brflag = (tok == INBRACE);
incasepat = 1;
incmdpos = 0;
+ noaliases = ona;
+ nocorrect = onc;
yylex();
for (;;) {
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page still at http://www.pwstephenson.fsnet.co.uk/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-03-26 18:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-26 13:22 Keyword Aliasing Behaviour Sean B. Palmer
2006-03-26 18:54 ` Peter Stephenson
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).