From owner-freebsd-bugs Mon Oct 27 12:00:05 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id MAA19216 for bugs-outgoing; Mon, 27 Oct 1997 12:00:05 -0800 (PST) (envelope-from owner-freebsd-bugs) Received: (from gnats@localhost) by hub.freebsd.org (8.8.7/8.8.7) id MAA19179; Mon, 27 Oct 1997 12:00:01 -0800 (PST) (envelope-from gnats) Resent-Date: Mon, 27 Oct 1997 12:00:01 -0800 (PST) Resent-Message-Id: <199710272000.MAA19179@hub.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@FreeBSD.ORG, fenner@parc.xerox.com Received: from alpha.xerox.com (alpha.Xerox.COM [13.1.64.93]) by hub.freebsd.org (8.8.7/8.8.7) with SMTP id LAA18776 for ; Mon, 27 Oct 1997 11:52:33 -0800 (PST) (envelope-from fenner@parc.xerox.com) Received: from klute.parc.xerox.com ([13.2.116.207]) by alpha.xerox.com with SMTP id <57071(5)>; Mon, 27 Oct 1997 11:51:53 PST Received: from sundae.parc.xerox.com ([13.2.117.33]) by klute.parc.xerox.com with SMTP id <59202>; Mon, 27 Oct 1997 11:51:47 PST Received: (from fenner@localhost) by sundae.parc.xerox.com (8.8.5/8.8.5) id LAA29325; Mon, 27 Oct 1997 11:51:46 -0800 (PST) Message-Id: <199710271951.LAA29325@sundae.parc.xerox.com> Date: Mon, 27 Oct 1997 11:51:46 PST From: Bill Fenner Reply-To: fenner@parc.xerox.com To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: docs/4866: Man pages for basename(1) and dirname(1) are wrong Sender: owner-freebsd-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >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: