@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
@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})
@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