Hi Eric,

* Eric Blake wrote on Wed, Mar 22, 2006 at 02:35:05PM CET:
> 
> 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.

Yep.  I always thought that was because `basename' is fairly portable.

> 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."

If you'd like an opinion, I'd still like a warning, maybe a bit weaker
than that.  The discussion about my pending documentation patch also
shows how immature it still is.

A small nit:

> [EMAIL PROTECTED] AS_BASENAME (@var{file-name})
> [EMAIL PROTECTED]
> +Return the filename portion of @var{file-name}, using the algorithm
> +required by Posix.  @xref{Limitations of Usual Tools}, for more

Required?  See below.

> +details about what this returns and why it is more portable than the
> [EMAIL PROTECTED] command.
> [EMAIL PROTECTED] 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}.
>  
> [EMAIL PROTECTED] @command{basename}
> [EMAIL PROTECTED] --------------------
> [EMAIL PROTECTED] @command{basename}
> +Not all hosts have a working @command{basename}, and you should instead
> +use @code{AS_BASENAME} (@pxref{Programming in M4sh}).  For example:
> +
> [EMAIL PROTECTED]
> +file=`basename "$file"`       # This is not portable.
> +file=`AS_BASENAME(["$file"])` # This is more portable.
> [EMAIL PROTECTED] example
> +
> +Unfortunately, neither of the above commands work if @code{$file} ends
> +in newline, since @[EMAIL PROTECTED] removes all trailing newlines.
> +
> [EMAIL PROTECTED]
> +This handles a few subtleties in the standard way required by
> +Posix.  For example, Posix permits implementations to treat leading
> [EMAIL PROTECTED]//} with special semantics,

I sense a contradiction between "required" and "permits" here.
Are there basename implementations that turn /// into ///?
If yes, that does not get very clear here, and I think the
previous quoted comment by Paul was a bit clearer here.

>                                     but requires leading @samp{///} and
> +beyond to be equivalent to @samp{/}.  While most flavors of Unix treat
> [EMAIL PROTECTED]//} 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 @[EMAIL PROTECTED] 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
> [EMAIL PROTECTED]/}?  Paul Eggert answers:
> -
> [EMAIL PROTECTED]
> -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
> [EMAIL PROTECTED]//}.  It says that the behavior of @command{dirname} on file 
> names of the
> -form @samp{//([^/]+/*)?} is implementation defined.  In these cases,
> [EMAIL PROTECTED] @command{dirname} returns @samp{/}, but those no-longer-used
> -flavors of Unix returned @samp{//}.
> [EMAIL PROTECTED] quotation
> +Similar to AS_BASENAME, AS_DIRNAME correctly handles leading @samp{//}.
>  
>  
>  @item @command{egrep}
>  @c ------------------
>  @prindex @command{egrep}


Reply via email to