bin/121520: [patch]: support for multiple arguments for dirname(1)
just as basename(1) does
Ighighi
ighighi at gmail.com
Sun Mar 9 14:10:01 UTC 2008
>Number: 121520
>Category: bin
>Synopsis: [patch]: support for multiple arguments for dirname(1) just as basename(1) does
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sun Mar 09 14:10:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator: Ighighi
>Release: 6.3-STABLE
>Organization:
>Environment:
FreeBSD orion 6.3-STABLE FreeBSD 6.3-STABLE #0: Mon Mar 3 04:45:31 VET 2008 root at orion:/usr/obj/usr/src/sys/CUSTOM i386
>Description:
This patch adds support for multiple arguments to dirname(1) like basename(1) has
been already. It's the natural thing to expect, both commands even share the
same manpage.
>How-To-Repeat:
>Fix:
Patch attached with submission follows:
#
# Note: both basename(1) and dirname(1) use basename(1)'s manpage
#
--- src/usr.bin/dirname/dirname.c.orig Sat May 21 05:55:05 2005
+++ src/usr.bin/dirname/dirname.c Thu May 3 18:09:12 2007
@@ -66,12 +66,15 @@
argc -= optind;
argv += optind;
- if (argc != 1)
+ if (argc < 1)
usage();
- if ((p = dirname(*argv)) == NULL)
- err(1, "%s", *argv);
- (void)printf("%s\n", p);
+ while (argc--) {
+ if ((p = dirname(*argv)) == NULL)
+ err(1, "%s", *argv);
+ argv++;
+ (void)printf("%s\n", p);
+ }
exit(0);
}
@@ -79,6 +82,6 @@
usage(void)
{
- (void)fprintf(stderr, "usage: dirname string\n");
+ (void)fprintf(stderr, "usage: dirname string [...]\n");
exit(1);
}
--- src/usr.bin/basename/basename.1.orig Tue Jan 18 09:43:47 2005
+++ src/usr.bin/basename/basename.1 Thu May 3 18:28:27 2007
@@ -52,6 +52,7 @@
.Op Ar ...
.Nm dirname
.Ar string
+.Op Ar ...
.Sh DESCRIPTION
The
.Nm
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list