1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-21 03:12:48 +02:00

Use a better dirname emulation.

* build-aux/check.mk (_dirname): Define.
(am__check_pre): Use it.
This commit is contained in:
Jim Meyering
2008-02-10 13:52:47 +01:00
parent 48b9ff8555
commit d80aaca2da

View File

@@ -90,9 +90,12 @@ tput sgr0 >/dev/null 2>&1 && \
SH_E_WORKAROUND = case $$- in *e*) set +e;; esac SH_E_WORKAROUND = case $$- in *e*) set +e;; esac
# Emulate dirname with sed. # Emulate dirname with sed.
# This approximation fails when the input is a single-component _d_no_slash = s,^[^/]*$$,.,
# absolute directory name like /foo, but that never happens here. _d_strip_trailing = s,\([^/]\)//*$$,\1,
approx_dirname_filter = sed 's,^[^/]*$$,.,;s,//*[^/]*$$,,' _d_abs_trivial = s,^//*[^/]*$$,/,
_d_rm_basename = s,\([^/]\)//*[^/]*$$,\1,
_dirname = \
sed '$(_d_no_slash);$(_d_strip_trailing);$(_d_abs_trivial);$(_d_rm_basename)'
# To be inserted before the command running the test. Creates the # To be inserted before the command running the test. Creates the
# directory for the log if needed. Stores in $dir the directory # directory for the log if needed. Stores in $dir the directory
@@ -101,7 +104,7 @@ am__check_pre = \
$(SH_E_WORKAROUND); \ $(SH_E_WORKAROUND); \
tst=`echo "$$src" | sed 's|^.*/||'`; \ tst=`echo "$$src" | sed 's|^.*/||'`; \
rm -f $@-t; \ rm -f $@-t; \
$(mkdir_p) "$$(echo '$@'|$(approx_dirname_filter))" || exit; \ $(mkdir_p) "$$(echo '$@'|$(_dirname))" || exit; \
if test -f "./$$src"; then dir=./; \ if test -f "./$$src"; then dir=./; \
elif test -f "$$src"; then dir=; \ elif test -f "$$src"; then dir=; \
else dir="$(srcdir)/"; fi; \ else dir="$(srcdir)/"; fi; \