Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Problematic change in alias behavior in pre3



On Jul 21, 10:41am, Bart Schaefer wrote:
} Subject: Problematic change in alias behavior in pre3
}
} zsh% alias show="noglob show"
} zsh% show=()
} zsh: parse error near `)'
} 
} Why does the existence of the alias mess up the variable assignment?

I don't know how/why this worked in pre2, but in pre3 gettokstr() returns
"show=stuff" for ENVSTRING, but only "show" for ENVARRAY.  Thus the token
"show" is incmdpos when when exalias(), and thus is subject to expansion.

It's not sufficient to assign incmdpos=0 when ENVARRAY, because then this
kind of thing fails:

zsh% alias foo='echo help'
zsh% show=(stuff) foo bar
zsh: command not found: foo

So here's what I came up with; I return tokstr "show=" from the lexer for
ENVARRAY, and then strip off the '=' when parsing, as is done for ENVSTRING.
It's impossible to create an alias name containing an '=' (maybe that's a
bug, too?) so exalias() can't possibly succeed on "show=".

*** Src/lex.c.0	Thu Jul 18 19:15:13 1996
--- Src/lex.c	Sun Jul 21 11:26:22 1996
***************
*** 853,858 ****
--- 853,859 ----
  		       incmdpos && !bct && !brct) {
  		e = hgetc();
  		if (e == '(' && incmdpos) {
+ 		    add('=');
  		    *bptr = '\0';
  		    return ENVARRAY;
  		}
*** Src/parse.c.0	Fri Jul 19 11:17:12 1996
--- Src/parse.c	Sun Jul 21 11:29:49 1996
***************
*** 916,922 ****
  
  	    v->type = PM_ARRAY;
  	    incmdpos = 0;
! 	    v->name = tokstr;
  	    cmdpush(CS_ARRAY);
  	    yylex();
  	    v->arr = par_nl_wordlist();
--- 916,922 ----
  
  	    v->type = PM_ARRAY;
  	    incmdpos = 0;
! 	    equalsplit(v->name = tokstr, &v->str);
  	    cmdpush(CS_ARRAY);
  	    yylex();
  	    v->arr = par_nl_wordlist();

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern

New male in /home/schaefer:
>N  2 Justin William Schaefer  Sat May 11 03:43  53/4040  "Happy Birthday"




Messages sorted by: Reverse Date, Date, Thread, Author