From a1251487f4a844ae23bd49ad326b0f1220df85fc Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Fri, 29 Oct 2010 21:20:56 +0000 Subject: [PATCH] =?UTF-8?q?sh:=20Reject=20function=20names=20ending=20in?= =?UTF-8?q?=20one=20of=20!%*+-=3D=3F@}~?= 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) --- bin/sh/parser.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/sh/parser.c b/bin/sh/parser.c index fa670f119d6..f4d38edd8f0 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -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 &&