summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2011-01-09 21:07:30 +0000
committerjilles <jilles@FreeBSD.org>2011-01-09 21:07:30 +0000
commit2a782244a979d547efd9b9a664b03682ee43762b (patch)
treedfc78a13bf1df40e16086dd9a22480b709aefe36 /tools
parent7864be44ec3b92093ab6b590e152838c38a31e8d (diff)
downloadFreeBSD-src-2a782244a979d547efd9b9a664b03682ee43762b.zip
FreeBSD-src-2a782244a979d547efd9b9a664b03682ee43762b.tar.gz
sh: Remove special %builtin PATH entry.
All builtins are now always found before a PATH search. Most ash derivatives have an undocumented feature where the presence of an entry "%builtin" in $PATH will cause builtins to be checked at that point of the PATH search, rather than before looking at any directories as documented in the man page (very old versions do document this feature). I am removing this feature from sh, as it complicates the code, may violate expectations (for example, /usr/bin/alias is very close to a forkbomb with PATH=/usr/bin:%builtin, only /usr/bin/builtin not being another link saves it) and appears to be unused (all the %builtin google code search finds is in some sort of ash source code). Note that aliases and functions took and take precedence above builtins. Because aliases work on a lexical level they can only ever be overridden on a lexical level (quoting or preceding 'builtin' or 'command'). Allowing override of functions via PATH does not really fit in the model of sh and it would work differently from %builtin if implemented. Note: POSIX says special builtins are found before functions. We comply to this because we do not allow functions with the same name as a special builtin. Silence from: freebsd-hackers@ (message sent 20101225) Discussed with: dougb
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/bin/sh/execution/path1.015
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/execution/path1.0 b/tools/regression/bin/sh/execution/path1.0
new file mode 100644
index 0000000..50829d6
--- /dev/null
+++ b/tools/regression/bin/sh/execution/path1.0
@@ -0,0 +1,15 @@
+# $FreeBSD$
+# Some builtins should not be overridable via PATH.
+
+set -e
+T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX)
+trap 'rm -rf ${T}' 0
+echo '#!/bin/sh
+echo bad' >"$T/cd"
+chmod 755 "$T/cd"
+cd /bin
+oPATH=$PATH
+PATH=$T:$PATH:%builtin
+cd /
+PATH=$oPATH
+[ "$(pwd)" = / ]
OpenPOWER on IntegriCloud