summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-10-26 09:26:00 -0600
committerEric Blake <ebb9@byu.net>2009-10-26 21:30:32 -0600
commit0f3f6bf6bf38f1ed9c85fe98d6ac7645bf10a6c3 (patch)
tree9e6b57d8ff87fad835d37dc684ed904d3f0aa7cb /tests
parent243f1b1c71136171a4da635a84f8e32ba3eb3c94 (diff)
downloadcoreutils-0f3f6bf6bf38f1ed9c85fe98d6ac7645bf10a6c3.tar.xz
doc: document PATH interactions with env
* doc/coreutils.texi (env invocation): Mention that PATH is modified prior to exec. * tests/misc/env: Test this.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/misc/env24
1 files changed, 21 insertions, 3 deletions
diff --git a/tests/misc/env b/tests/misc/env
index 07dd9e468..e1e51ed29 100755
--- a/tests/misc/env
+++ b/tests/misc/env
@@ -51,9 +51,16 @@ test $? = 126 || fail=1
env no_such # no such command
test $? = 127 || fail=1
-# Cygwin requires a minimal environment to launch new processes, so a
-# subsequent env will show more than just what we set. Hence, it is
-# more portable to grep that our desired changes took place.
+# POSIX is clear that environ may, but need not be, sorted.
+# Environment variable values may contain newlines, which cannot be
+# observed by merely inspecting output from env.
+# Cygwin requires a minimal environment to launch new processes: execve
+# adds missing variables SYSTEMROOT and WINDIR, which show up in a
+# subsequent env. Cygwin also requires /bin to always be part of PATH,
+# and attempts to unset or reduce PATH may cause execve to fail.
+#
+# For these reasons, it is more portable to grep that our desired changes
+# took place, rather than comparing output of env over an entire environment.
if env | grep '^ENV_TEST' >/dev/null ; then
skip_test_ "environment has potential interference from ENV_TEST*"
fi
@@ -85,6 +92,17 @@ ENV_TEST1=b
EOF
compare exp out || fail=1
+# PATH modifications affect exec.
+mkdir unlikely_name || framework_failure
+cat <<EOF > unlikely_name/also_unlikely || framework_failure
+#!/bin/sh
+echo pass
+EOF
+chmod +x unlikely_name/also_unlikely || framework_failure
+env also_unlikely && fail=1
+test x`PATH=$PATH:unlikely_name env also_unlikely` = xpass || fail=1
+test x`env PATH="$PATH":unlikely_name also_unlikely` = xpass || fail=1
+
# Use -- to end arguments.
ln -s "$abs_top_builddir/src/echo" ./-i || framework_failure
case `PATH="$PATH:" env -i echo good` in