Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Oct 1997 11:51:46 PST
From:      Bill Fenner <fenner@parc.xerox.com>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   docs/4866: Man pages for basename(1) and dirname(1) are wrong
Message-ID:  <199710271951.LAA29325@sundae.parc.xerox.com>
Resent-Message-ID: <199710272000.MAA19179@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         4866
>Category:       docs
>Synopsis:       Man pages for basename(1) and dirname(1) are wrong
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 27 12:00:00 PST 1997
>Last-Modified:
>Originator:     Bill Fenner
>Organization:
Xerox
>Release:        FreeBSD 2.2.2-RELEASE i386
>Environment:

	
All versions of FreeBSD

>Description:

	
The man page for basename/dirname states:

	... If string ends in the slash character, `/',
     or is the same as the suffix argument, a newline is output.  ...

     Dirname deletes the filename portion, beginning with the last slash `/'
     character to the end of string, and writes the result to the standard
     output.

Neither of the statements in the first sentence are true.  The sentence
about dirname is false if the argument ends in a slash.

The utilities themselves appear to conform to POSIX 1003.2; it's just
the description of their behavior in the man page that's wrong.

>How-To-Repeat:

	
% man basename
% man dirname
% basename /tmp/foo/bar/
bar
% basename foo foo
foo
% dirname /tmp/foo/bar/
/tmp/foo

>Fix:
	
	

Index: /usr/src/usr.bin/basename/basename.1
--- basename.1.orig	Mon Oct 27 11:43:45 1997
+++ basename.1	Mon Oct 27 11:50:11 1997
@@ -52,19 +52,16 @@
 deletes any prefix ending with the last slash
 .Ql \&/
 character present in
-.Ar string ,
+.Ar string
+(after first stripping trailing slashes),
 and a
 .Ar suffix ,
 if given.
-The resulting filename is written to the standard output.
-If
-.Ar string
-ends in the slash character,
-.Ql / ,
-or is the same as the
+The
 .Ar suffix
-argument,
-a newline is output.
+is not stripped if it is identical to the remaining characters in
+.Ar string .
+The resulting filename is written to the standard output.
 A non-existent suffix is ignored.
 .Pp
 .Nm Dirname
@@ -72,7 +69,8 @@
 with the last slash
 .Ql \&/
 character to the end of
-.Ar string , 
+.Ar string
+(after first stripping trailing slashes), 
 and writes the result to the standard output.
 .Sh EXAMPLES 
 The following line sets the shell variable
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199710271951.LAA29325>