Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh Allow function names to be any shell word not contain...



details:   https://anonhg.NetBSD.org/src/rev/90ce31752e79
branches:  trunk
changeset: 345023:90ce31752e79
user:      kre <kre%NetBSD.org@localhost>
date:      Tue May 03 03:16:55 2016 +0000

description:
Allow function names to be any shell word not containing '/'.
This allows anything that could be a filesystem command to be
implemented as a function instead.  The restriction on '/'
is because of the way that functions are (required to be) searched
for relative to PATH searching - a function with a name containing '/'
could never be executed, so simply prohibit defining such a thing.

ok christos@

diffstat:

 bin/sh/parser.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 3fa8e5ef95f3 -r 90ce31752e79 bin/sh/parser.c
--- a/bin/sh/parser.c   Tue May 03 03:12:40 2016 +0000
+++ b/bin/sh/parser.c   Tue May 03 03:16:55 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parser.c,v 1.117 2016/05/02 01:46:31 christos Exp $    */
+/*     $NetBSD: parser.c,v 1.118 2016/05/03 03:16:55 kre Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)parser.c   8.7 (Berkeley) 5/16/95";
 #else
-__RCSID("$NetBSD: parser.c,v 1.117 2016/05/02 01:46:31 christos Exp $");
+__RCSID("$NetBSD: parser.c,v 1.118 2016/05/03 03:16:55 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -597,7 +597,7 @@
                                synexpect(TRP, 0);
                        funclinno = plinno;
                        rmescapes(n->narg.text);
-                       if (!goodname(n->narg.text))
+                       if (strchr(n->narg.text, '/'))
                                synerror("Bad function name");
                        n->type = NDEFUN;
                        n->narg.next = command();



Home | Main Index | Thread Index | Old Index