sh: Reject function names ending in one of !%*+-=?@}~

These do something else in ksh: name=(...) is an array or compound variable
assignment and the others are extended patterns.

This is the last patch of the ones tested in the exp run.

Exp-run done by:	pav (with some other sh(1) changes)
This commit is contained in:
Jilles Tjoelker 2010-10-29 21:20:56 +00:00
parent a12be66e86
commit a1251487f4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=214534

View File

@ -644,9 +644,13 @@ simplecmd(union node **rpp, union node *redir)
/*
* - Require plain text.
* - Functions with '/' cannot be called.
* - Reject name=().
* - Reject ksh extended glob patterns.
*/
if (!noexpand(n->narg.text) || quoteflag ||
strchr(n->narg.text, '/'))
strchr(n->narg.text, '/') ||
strchr("!%*+-=?@}~",
n->narg.text[strlen(n->narg.text) - 1]))
synerror("Bad function name");
rmescapes(n->narg.text);
if (find_builtin(n->narg.text, &special) >= 0 &&