aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/basename
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/basename')
-rw-r--r--usr.bin/basename/Makefile3
-rw-r--r--usr.bin/basename/basename.119
-rw-r--r--usr.bin/basename/basename.c19
3 files changed, 23 insertions, 18 deletions
diff --git a/usr.bin/basename/Makefile b/usr.bin/basename/Makefile
index f31a89a699d5..d29e796b269b 100644
--- a/usr.bin/basename/Makefile
+++ b/usr.bin/basename/Makefile
@@ -1,4 +1,5 @@
-# @(#)Makefile 5.2 (Berkeley) 5/11/90
+# from: @(#)Makefile 5.2 (Berkeley) 5/11/90
+# $Id: Makefile,v 1.2 1993/11/23 00:01:04 jtc Exp $
PROG= basename
MLINKS= basename.1 dirname.1
diff --git a/usr.bin/basename/basename.1 b/usr.bin/basename/basename.1
index 2568d4485ef8..8f332628817f 100644
--- a/usr.bin/basename/basename.1
+++ b/usr.bin/basename/basename.1
@@ -32,7 +32,8 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)basename.1 6.7 (Berkeley) 6/27/91
+.\" from: @(#)basename.1 6.7 (Berkeley) 6/27/91
+.\" $Id: basename.1,v 1.2.2.1 1994/05/01 16:08:06 jkh Exp $
.\"
.Dd June 27, 1991
.Dt BASENAME 1
@@ -56,15 +57,7 @@ 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
-.Ar suffix
-argument,
-a newline is output.
-A non-existant suffix is ignored.
+A non-existent suffix is ignored.
.Pp
.Nm Dirname
deletes the filename portion, beginning
@@ -85,13 +78,15 @@ Both the
.Nm basename
and
.Nm dirname
+utilities
exit 0 on success, and >0 if an error occurs.
.Sh SEE ALSO
-.Xr csh 1
+.Xr csh 1 ,
.Xr sh 1
.Sh STANDARDS
The
.Nm basename
and
.Nm dirname
-functions are expected to be POSIX 1003.2 compatible.
+utilities conform to
+.St -p1003.2-92 .
diff --git a/usr.bin/basename/basename.c b/usr.bin/basename/basename.c
index 18ff63686de0..29c43bf41660 100644
--- a/usr.bin/basename/basename.c
+++ b/usr.bin/basename/basename.c
@@ -38,22 +38,28 @@ char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)basename.c 5.1 (Berkeley) 3/9/91";
+/*static char sccsid[] = "from: @(#)basename.c 5.1 (Berkeley) 3/9/91";*/
+static char rcsid[] = "$Id: basename.c,v 1.2 1993/11/23 00:01:06 jtc Exp $";
#endif /* not lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <locale.h>
+static void usage __P((void));
+
+int
main(argc, argv)
int argc;
char **argv;
{
- extern int optind;
register char *p;
int ch;
- while ((ch = getopt(argc, argv, "")) != EOF)
+ setlocale(LC_ALL, "");
+
+ while ((ch = getopt(argc, argv, "")) != -1)
switch(ch) {
case '?':
default:
@@ -89,8 +95,10 @@ main(argc, argv)
* (3) If there are any trailing slash characters in string, they
* shall be removed.
*/
- for (; *p; ++p);
- while (*--p == '/');
+ for (; *p; ++p)
+ ;
+ while (*--p == '/')
+ ;
*++p = '\0';
/*
@@ -125,6 +133,7 @@ main(argc, argv)
exit(0);
}
+static void
usage()
{
(void)fprintf(stderr, "usage: basename string [suffix]\n");