summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2010-10-24 22:03:21 +0000
committerjilles <jilles@FreeBSD.org>2010-10-24 22:03:21 +0000
commit58038d3e9e1f45ea4dccdfeb21e3f9bb40ae4950 (patch)
treec67a589303115497405ea6d6c7c7ed067acf7e9f /tools
parent520543ca439ef2838b69c6bf1e321ba7ce98debf (diff)
downloadFreeBSD-src-58038d3e9e1f45ea4dccdfeb21e3f9bb40ae4950.zip
FreeBSD-src-58038d3e9e1f45ea4dccdfeb21e3f9bb40ae4950.tar.gz
sh: Do not allow overriding a special builtin with a function.
This is a syntax error. POSIX does not say explicitly whether defining a function with the same name as a special builtin is allowed, but it does say that it is impossible to call such a function. A special builtin can still be overridden with an alias. This commit is part of a set of changes that will ensure that when something looks like a special builtin to the parser, it is one. (Not the other way around, as it remains possible to call a special builtin named by a variable or other substitution.) Exp-run done by: pav (with some other sh(1) changes)
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/bin/sh/execution/func3.07
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/execution/func3.0 b/tools/regression/bin/sh/execution/func3.0
new file mode 100644
index 0000000..f7a562a
--- /dev/null
+++ b/tools/regression/bin/sh/execution/func3.0
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+# This may fail when parsing or when defining the function, or the definition
+# may silently do nothing. In no event may the function be executed.
+
+sh -c 'unset() { echo overriding function executed, bad; }; v=1; unset v; exit "${v-0}"' 2>/dev/null
+:
OpenPOWER on IntegriCloud