]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
(Programming in M4sh, Limitations of Usual Tools):
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 31 Mar 2006 06:08:36 +0000 (06:08 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 31 Mar 2006 06:08:36 +0000 (06:08 +0000)
Tighten up the basename/dirname wording.

doc/autoconf.texi

index 15218b7da30691d2d40897ae67ac9cdcfa676531..69aac5cf2ded44bef0e5b93d5474684b9d0f9bca 100644 (file)
@@ -9386,9 +9386,9 @@ that unfortunately are not portable in practice.
 @defmac AS_BASENAME (@var{file-name})
 @asindex{BASENAME}
 Output the non-directory portion of @var{file-name}.  For example,
-@code{AS_BASENAME([/one/two/three])} outputs @samp{three}.
-@xref{Limitations of Usual Tools}, for more details about what this
-returns and why it is more portable than the @command{basename} command.
+@code{file=`AS_BASENAME([/one/two/three])`} sets @code{file} to
+@samp{three}.  @xref{Limitations of Usual Tools}, for why this is more
+portable than @command{file=`basename /one/two/three`}.
 @end defmac
 
 @defmac AS_BOURNE_COMPATIBLE
@@ -9409,9 +9409,9 @@ corresponding pattern matched @var{word}, else @var{default} is run.
 @defmac AS_DIRNAME (@var{file-name})
 @asindex{DIRNAME}
 Output the directory portion of @var{file-name}.  For example,
-@code{AS_DIRNAME([/one/two/three])} outputs @samp{/one/two}.
-@xref{Limitations of Usual Tools}, for more details about what this
-returns and why it is more portable than the @command{dirname} command.
+@code{file=`AS_DIRNAME([/one/two/three])`} sets @code{file} to
+@samp{/one/two}.  @xref{Limitations of Usual Tools}, for why this is
+more portable than @command{file=`dirname /one/two/three`}.
 @end defmac
 
 @defmac AS_IF (@var{test1}, @ovar{run-if-true1}, @dots{}, @ovar{run-if-false})
@@ -12183,11 +12183,21 @@ fields in a record.  You may be able to circumvent this problem by using
 @c ---------------------
 @prindex @command{basename}
 Not all hosts have a working @command{basename}, and you should instead
-use @code{AS_BASENAME} (@pxref{Programming in M4sh}).  For example:
+use @code{AS_BASENAME} (@pxref{Programming in M4sh}), followed by
+@command{expr} if you need to strip a suffix.  For example:
 
 @example
-file=`basename "$file"`       # This is not portable.
-file=`AS_BASENAME(["$file"])` # This is more portable.
+a=`basename "$aname"`       # This is not portable.
+a=`AS_BASENAME(["$aname"])` # This is more portable.
+
+# This is not portable.
+c=`basename "$cname" .c`
+
+# This is more portable.
+c=`AS_BASENAME(["$cname"])`
+case $c in
+?*.c) c=`expr "X$c" : 'X\(.*\)\.c'`;;
+esac
 @end example