zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: "Sean B. Palmer" <sean@miscoranda.com>, zsh-users@sunsite.dk
Subject: Re: Keyword Aliasing Behaviour
Date: Sun, 26 Mar 2006 19:54:06 +0100	[thread overview]
Message-ID: <200603261854.k2QIs63D004915@pwslaptop.csr.com> (raw)
In-Reply-To: Message from "Sean B. Palmer" <sean@miscoranda.com>  of "Sun, 26 Mar 2006 14:22:32 BST." <b6bb4d890603260522t56472c8bufd976d75676f8359@mail.gmail.com>

"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/


      reply	other threads:[~2006-03-26 18:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-26 13:22 Sean B. Palmer
2006-03-26 18:54 ` Peter Stephenson [this message]

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=200603261854.k2QIs63D004915@pwslaptop.csr.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=sean@miscoranda.com \
    --cc=zsh-users@sunsite.dk \
    /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).