17692: Prevent typeset of a positional parameter before it can do damage,

and improve the error message about it.
This commit is contained in:
Bart Schaefer 2002-09-19 17:57:56 +00:00
parent 41b50445ea
commit a1d727e5dc
2 changed files with 10 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2002-09-19 Bart Schaefer <schaefer@zsh.org>
* 17692: Src/builtin.c: Prevent typeset of a positional parameter
before it can do damage, and improve the error message about it.
2002-09-17 Peter Stephenson <pws@csr.com>
* 17673: Src/exec.c, Test/A01grammar.ztst:

View file

@ -1909,7 +1909,7 @@ typeset_single(char *cname, char *pname, Param pm, int func,
"%s: array elements must be scalar", pname, 0);
return NULL;
}
} else if (isident(pname)) {
} else if (isident(pname) && !idigit(*pname)) {
/*
* Create a new node for a parameter with the flags in `on' minus the
* readonly flag
@ -1918,7 +1918,10 @@ typeset_single(char *cname, char *pname, Param pm, int func,
DPUTS(!pm, "BUG: parameter not created");
pm->ct = auxlen;
} else {
zerr("not an identifier: %s", pname, 0);
if (isident(pname))
zerrnam(cname, "not valid in this context: %s", pname, 0);
else
zerrnam(cname, "not an identifier: %s", pname, 0);
return NULL;
}