echo|sed.
From Paul Eggert.
* doc/autoconf.texi (Limitations of Usual Tools): Include the
words from Paul about `|' with expr(1).
+2000-07-10 Akim Demaille <akim@epita.fr>
+
+ * acgeneral.m4 (AC_DIRNAME): Use an `expr' solution instead of
+ echo|sed.
+ From Paul Eggert.
+ * doc/autoconf.texi (Limitations of Usual Tools): Include the
+ words from Paul about `|' with expr(1).
+
2000-07-10 Akim Demaille <akim@epita.fr>
* aclang.m4: Promote s,,, over s%%%, and `sed prog' over `sed -e
# ---------------------------
# Simulate running `dirname(1)' on PATHNAME, not all systems have it.
# This macro must be usable from inside ` `.
+#
+# Paul Eggert answers:
+# Question: Under UN*X, should `//1' give `/'?
+#
+# No, under some older flavors of Unix, leading // is a special path
+# name: it refers to a "super-root" and is used to access other
+# machines' files. Leading ///, ////, etc. are equivalent to /; but
+# leading // is special. I think this tradition started with Apollo
+# Domain/OS, an OS that is still in use on some older hosts.
+#
+# POSIX.2 allows but does not require the special treatment for //.
+# It says that the behavior of dirname on path names of the form
+# //([^/]+/*)? is implementation defined. In these cases, GNU dirname
+# returns /, but it's more portable to return // as this works even on
+# those older flavors of Unix.
+#
+# I have heard rumors that this special treatment of // may be dropped
+# in future versions of POSIX, but for now it's still the standard.
define([_AC_SHELL_DIRNAME],
-[echo $1 | sed '/^\/*$/!s,//*$,,;s,[[^/]]*$,,;s,//*$,/,;/^\/$/!s,/$,,;s,^$,.,'])
-
+[expr "X$dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ "X$dir" : 'X\(//\)[^/]' \| \
+ "X$dir" : 'X\(//\)$' \| \
+ "X$dir" : 'X\(/\)' \| \
+ . : '\(.\)'])
## --------------------------------------------------- ##
@command{egrep} also suffers the limitations of @command{grep}.
+
@item @command{expr}
@cindex @command{expr}
-Don't use @samp{\?}, @samp{\+} and @samp{\|} in patterns, they are
-not supported on Solaris.
-
No @command{expr} keyword starts with @samp{x}, so use @samp{expr
x"@var{word}" : '@var{regex}'} to keep @command{expr} from
misinterpreting @var{word}.
+You can use @samp{|}. There is one portability problem occuring when
+you @samp{|} together the empty string (or zero) with the empty string.
+For example:
+
+@example
+expr '' \| ''
+@end example
+
+@sc{gnu}/Linux and @sc{posix.2} return the empty string for this case,
+but traditional Unix returns @samp{0}. In the latest @sc{posix} draft,
+the specification has been changed to match traditional Unix's behavior
+(which is bizarre, but it's too late to fix this).
+
+Avoid this portability problem by avoiding the empty string.
+
+
+
Don't use @code{length}, @code{substr}, @code{match} and @code{index}.
+@item @command{expr} (@samp{:})
+@cindex @command{expr}
+Don't use @samp{\?}, @samp{\+} and @samp{\|} in patterns, they are
+not supported on Solaris.
+
+
+
@item @command{grep}
@cindex @command{grep}
Don't use @samp{grep -s} to suppress output, because @samp{grep -s} on
# ---------------------------
# Simulate running `dirname(1)' on PATHNAME, not all systems have it.
# This macro must be usable from inside ` `.
+#
+# Paul Eggert answers:
+# Question: Under UN*X, should `//1' give `/'?
+#
+# No, under some older flavors of Unix, leading // is a special path
+# name: it refers to a "super-root" and is used to access other
+# machines' files. Leading ///, ////, etc. are equivalent to /; but
+# leading // is special. I think this tradition started with Apollo
+# Domain/OS, an OS that is still in use on some older hosts.
+#
+# POSIX.2 allows but does not require the special treatment for //.
+# It says that the behavior of dirname on path names of the form
+# //([^/]+/*)? is implementation defined. In these cases, GNU dirname
+# returns /, but it's more portable to return // as this works even on
+# those older flavors of Unix.
+#
+# I have heard rumors that this special treatment of // may be dropped
+# in future versions of POSIX, but for now it's still the standard.
define([_AC_SHELL_DIRNAME],
-[echo $1 | sed '/^\/*$/!s,//*$,,;s,[[^/]]*$,,;s,//*$,/,;/^\/$/!s,/$,,;s,^$,.,'])
-
+[expr "X$dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ "X$dir" : 'X\(//\)[^/]' \| \
+ "X$dir" : 'X\(//\)$' \| \
+ "X$dir" : 'X\(/\)' \| \
+ . : '\(.\)'])
## --------------------------------------------------- ##
-.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.020.
-.TH AUTOCONF "1" "June 2000" "GNU autoconf 2.14a" FSF
+.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.022.
+.TH AUTOCONF "1" "July 2000" "GNU autoconf 2.14a" FSF
.SH NAME
autoconf \- Generate configuration scripts
.SH SYNOPSIS
-.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.020.
-.TH AUTOHEADER "1" "June 2000" "GNU autoconf 2.14a" FSF
+.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.022.
+.TH AUTOHEADER "1" "July 2000" "GNU autoconf 2.14a" FSF
.SH NAME
autoheader \- Create a template header for configure
.SH SYNOPSIS
-.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.020.
-.TH AUTOUPDATE "1" "June 2000" "GNU autoconf 2.14a" FSF
+.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.022.
+.TH AUTOUPDATE "1" "July 2000" "GNU autoconf 2.14a" FSF
.SH NAME
autoupdate \- Update a configure.in to a newer Autoconf
.SH SYNOPSIS