summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2008-02-10 11:26:57 +0100
committerJim Meyering <meyering@redhat.com>2008-02-10 11:26:57 +0100
commit48b9ff855506b544b7670bb28989622ea283b79b (patch)
tree6bbd7a1f018cd6f631c020894e04cb8796f4042f
parentb0823fb4159a3416fd8ec33dbaa1693835d54154 (diff)
downloadcoreutils-48b9ff855506b544b7670bb28989622ea283b79b.tar.xz
Avoid test failure when run with risky PATH ("." before /usr/bin).
* build-aux/check.mk (approx_dirname_filter): Define. (am__check_pre): Emulate dirname using sed. Report and suggested fix from Bruno Haible in http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/12587/focus=12590
-rw-r--r--build-aux/check.mk7
1 files changed, 6 insertions, 1 deletions
diff --git a/build-aux/check.mk b/build-aux/check.mk
index 34169f50d..f35007bb0 100644
--- a/build-aux/check.mk
+++ b/build-aux/check.mk
@@ -89,6 +89,11 @@ tput sgr0 >/dev/null 2>&1 && \
# by disabling -e (using the XSI extension "set +e") if it's set.
SH_E_WORKAROUND = case $$- in *e*) set +e;; esac
+# Emulate dirname with sed.
+# This approximation fails when the input is a single-component
+# absolute directory name like /foo, but that never happens here.
+approx_dirname_filter = sed 's,^[^/]*$$,.,;s,//*[^/]*$$,,'
+
# To be inserted before the command running the test. Creates the
# directory for the log if needed. Stores in $dir the directory
# containing $src, and passes TESTS_ENVIRONMENT.
@@ -96,7 +101,7 @@ am__check_pre = \
$(SH_E_WORKAROUND); \
tst=`echo "$$src" | sed 's|^.*/||'`; \
rm -f $@-t; \
-$(mkdir_p) "$$(dirname $@)" || exit; \
+$(mkdir_p) "$$(echo '$@'|$(approx_dirname_filter))" || exit; \
if test -f "./$$src"; then dir=./; \
elif test -f "$$src"; then dir=; \
else dir="$(srcdir)/"; fi; \