-.\" $NetBSD: basename.1,v 1.11 1997/11/15 20:16:16 msaitoh Exp $
-.\"
.\" Copyright (c) 1990, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
.\" SUCH DAMAGE.
.\"
.\" @(#)basename.1 8.2 (Berkeley) 4/18/94
+.\" $FreeBSD: src/usr.bin/basename/basename.1,v 1.13 2002/06/30 13:40:35 jmallett Exp $
.\"
.Dd April 18, 1994
.Dt BASENAME 1
.Os
.Sh NAME
-.Nm basename ,
-.Nm dirname
+.Nm basename , dirname
.Nd return filename or directory portion of pathname
.Sh SYNOPSIS
.Nm
.Ar string
.Op Ar suffix
+.Nm
+.Op Fl a
+.Op Fl s Ar suffix
+.Ar string
+.Op Ar ...
.Nm dirname
.Ar string
.Sh DESCRIPTION
+The
.Nm
-deletes any prefix ending with the last slash
+utility 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
+.Ar suffix
+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.
+If
+.Fl a
+is specified, then every argument is treated as a
+.Ar string
+as if
+.Nm
+were invoked with just one argument.
+If
+.Fl s
+is specified, then the
+.Ar suffix
+is taken as its argument, and all other arguments are treated as a
+.Ar string .
.Pp
+The
.Nm dirname
-deletes the filename portion, beginning
+utility deletes the filename portion, beginning
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
+.Sh EXAMPLES
The following line sets the shell variable
.Ev FOO
to
.Pa /usr/bin .
.Pp
.Dl FOO=`dirname /usr/bin/trail`
-.Sh DIAGNOSTICS
-Both the
-.Nm
-and
-.Nm dirname
-utilities
-exit 0 on success, and >0 if an error occurs.
+.Sh DIAGNOSTICS
+.Ex -std basename dirname
.Sh SEE ALSO
.Xr csh 1 ,
.Xr sh 1
.Nm
and
.Nm dirname
-utilities conform to
-.St -p1003.2-92 .
+utilities are expected to be
+.St -p1003.2
+compatible.