summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2010-10-24 20:45:13 +0000
committerjilles <jilles@FreeBSD.org>2010-10-24 20:45:13 +0000
commite5f0dbf76ca1039abc78f0a61e6562f88e73326b (patch)
treee267217dcd6626c2c419ec08a528e096dde4f3cf /tools
parentc487e17b8fb428abe374fa4820d1b3628c383af5 (diff)
downloadFreeBSD-src-e5f0dbf76ca1039abc78f0a61e6562f88e73326b.zip
FreeBSD-src-e5f0dbf76ca1039abc78f0a61e6562f88e73326b.tar.gz
sh: Make sure defined functions can actually be called.
Add some conservative checks on function names: - Disallow expansions or quoting characters; these can only be called via strange control characters - Disallow '/'; these functions cannot be called anyway, as exec.c assumes they are pathnames - Make the CTL* bytes work properly in function names. These are syntax errors. POSIX does not require us to support more than names (letters, digits and underscores, not starting with a digit), but I do not want to restrict it that much at this time. Exp-run done by: pav (with some other sh(1) changes)
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/bin/sh/parser/func1.025
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/parser/func1.0 b/tools/regression/bin/sh/parser/func1.0
new file mode 100644
index 0000000..4e887b2
--- /dev/null
+++ b/tools/regression/bin/sh/parser/func1.0
@@ -0,0 +1,25 @@
+# $FreeBSD$
+# POSIX does not require these bytes to work in function names,
+# but making them all work seems a good goal.
+
+failures=0
+unset LC_ALL
+export LC_CTYPE=en_US.ISO8859-1
+i=128
+set -f
+while [ "$i" -le 255 ]; do
+ c=$(printf \\"$(printf %o "$i")")
+ ok=0
+ eval "$c() { ok=1; }"
+ $c
+ ok1=$ok
+ ok=0
+ "$c"
+ if [ "$ok" != 1 ] || [ "$ok1" != 1 ]; then
+ echo "Bad results for character $i" >&2
+ : $((failures += 1))
+ fi
+ unset -f $c
+ i=$((i+1))
+done
+exit $((failures > 0))
OpenPOWER on IntegriCloud