autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

document AS_BASENAME


From: Eric Blake
Subject: document AS_BASENAME
Date: Wed, 22 Mar 2006 06:35:05 -0700
User-agent: Thunderbird 1.5 (Windows/20051201)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

After my recent patch submission to coreutils, GNU dirname/basename will
now return // on platforms (for now, cygwin) that have // distinct from /.
 So the documentation needs an update; in the process, I noticed that
AS_DIRNAME is documented but not AS_BASENAME.

Also, do we want to remove this line about m4sh, that was picked up in the
context of my first hunk? "For the time being, it is not mature enough to
be widely used."

2006-03-22  Eric Blake  <address@hidden>

        * doc/autoconf.texi (Limitations of Usual Tools): Document
        basename.  Mention cygwin's treatment of //.
        (Programming in M4sh): Document AS_BASENAME.

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEIVKI84KuGfSFAYARAhu9AKCa6ma61ZCxkYAgusC9cuYSxK3DOQCgooNK
bRZ0YP0CKYlcsX1SqQT4zjg=
=W9WU
-----END PGP SIGNATURE-----
Index: doc/autoconf.texi
===================================================================
RCS file: /sources/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.971
diff -u -p -U5 -r1.971 autoconf.texi
--- doc/autoconf.texi   21 Mar 2006 21:51:07 -0000      1.971
+++ doc/autoconf.texi   22 Mar 2006 13:32:02 -0000
@@ -9377,10 +9377,18 @@ A mess; trouble.  [Obs.] --Beau.@: & Fl.
 For the time being, it is not mature enough to be widely used.
 
 M4sh provides portable alternatives for some common shell constructs
 that unfortunately are not portable in practice.
 
address@hidden AS_BASENAME (@var{file-name})
address@hidden
+Return the filename portion of @var{file-name}, using the algorithm
+required by Posix.  @xref{Limitations of Usual Tools}, for more
+details about what this returns and why it is more portable than the
address@hidden command.
address@hidden defmac
+
 @defmac AS_BOURNE_COMPATIBLE
 @asindex{BOURNE_COMPATIBLE}
 Set up the shell to be more compatible with the Bourne shell as
 standardized by Posix, if possible.  This may involve setting
 environment variables, or setting options, or similar
@@ -12156,10 +12164,35 @@ Traditional Awk @code{split} supports on
 
 Traditional Awk has a limit of 99
 fields in a record.  You may be able to circumvent this problem by using
 @code{split}.
 
address@hidden @command{basename}
address@hidden --------------------
address@hidden @command{basename}
+Not all hosts have a working @command{basename}, and you should instead
+use @code{AS_BASENAME} (@pxref{Programming in M4sh}).  For example:
+
address@hidden
+file=`basename "$file"`       # This is not portable.
+file=`AS_BASENAME(["$file"])` # This is more portable.
address@hidden example
+
+Unfortunately, neither of the above commands work if @code{$file} ends
+in newline, since @address@hidden removes all trailing newlines.
+
address@hidden
+This handles a few subtleties in the standard way required by
+Posix.  For example, Posix permits implementations to treat leading
address@hidden//} with special semantics, but requires leading @samp{///} and
+beyond to be equivalent to @samp{/}.  While most flavors of Unix treat
address@hidden//} identically to @samp{/}, there are some which treat it as a
+``super-root'' where it can provide access to other machines' files.
+This tradition started with Apollo Domain/OS, and continues today with
+Cygwin.
+
+
 @item @command{cat}
 @c ----------------
 @prindex @command{cat}
 Don't rely on any option.
 
@@ -12329,27 +12362,11 @@ dir=`AS_DIRNAME(["$file"])` # This is mo
 Unfortunately, neither of the above commands work if @code{$file}'s
 directory name ends in newline, since @address@hidden removes all
 trailing newlines.
 
 @noindent
-This handles a few subtleties in the standard way required by
-Posix.  For example, under UN*X, should @samp{dirname //1} give
address@hidden/}?  Paul Eggert answers:
-
address@hidden
-No, under some older flavors of Unix, leading @samp{//} is a special
-file name: it refers to a ``super-root'' and is used to access other
-machines' files.  Leading @samp{///}, @samp{////}, etc.@: are equivalent
-to @samp{/}; but leading @samp{//} is special.  This tradition
-started with Apollo Domain/OS, though it has largely died out in practice.
-
-Posix allows but does not require the special treatment for
address@hidden//}.  It says that the behavior of @command{dirname} on file 
names of the
-form @samp{//([^/]+/*)?} is implementation defined.  In these cases,
address@hidden @command{dirname} returns @samp{/}, but those no-longer-used
-flavors of Unix returned @samp{//}.
address@hidden quotation
+Similar to AS_BASENAME, AS_DIRNAME correctly handles leading @samp{//}.
 
 
 @item @command{egrep}
 @c ------------------
 @prindex @command{egrep}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]