+2000-07-06 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
+
+ * acgeneral.m4 (_AC_SHELL_DIRNAME): Behave properly when the
+ argument is a dir with trailing slashes, and when its depth is
+ just one (`/tmp').
+
2000-07-06 Lars J. Aas <larsa@sim.no>
* acgeneral.m4 (_AC_SHELL_DIRNAME): New macro.
# _AC_SHELL_DIRNAME(PATHNAME)
# ---------------------------
-# Remove last slash and trailing text.
-# Not all systems have dirname, so we emulate it with sed.
+# Simulate running `dirname(1)' on PATHNAME, not all systems have it.
# This macro must be usable from inside ` `.
define([_AC_SHELL_DIRNAME],
-[echo $1 | sed 's%/[[^/][^/]]*$%%'])
+[echo $1 | sed '/^\/*$/!s,//*$,,;s,[^/]*$,,;s,//*$,/,;/^\/$/!s,/$,,'])
# _AC_SHELL_DIRNAME(PATHNAME)
# ---------------------------
-# Remove last slash and trailing text.
-# Not all systems have dirname, so we emulate it with sed.
+# Simulate running `dirname(1)' on PATHNAME, not all systems have it.
# This macro must be usable from inside ` `.
define([_AC_SHELL_DIRNAME],
-[echo $1 | sed 's%/[[^/][^/]]*$%%'])
+[echo $1 | sed '/^\/*$/!s,//*$,,;s,[^/]*$,,;s,//*$,/,;/^\/$/!s,/$,,'])