Alow dirname(1) to accept multiple arguments in the same way that

basename(1) does.

(Two different PRs contained identical patches, both cited below)

PR:		121520, 86148
Submitted by:	Ighighi <ighighi at gmail dot com>
Submitted by:	Leif Neland <leif at neland dot dk>
MFC after:	3 days
This commit is contained in:
rwatson 2009-02-02 11:19:56 +00:00
parent af5756126e
commit 0239a09bb6
2 changed files with 9 additions and 5 deletions

View File

@ -52,6 +52,7 @@
.Op Ar ...
.Nm dirname
.Ar string
.Op Ar ...
.Sh DESCRIPTION
The
.Nm

View File

@ -66,12 +66,15 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
if (argc != 1)
if (argc < 1)
usage();
while (argc--) {
if ((p = dirname(*argv)) == NULL)
err(1, "%s", *argv);
argv++;
(void)printf("%s\n", p);
}
exit(0);
}
@ -79,6 +82,6 @@ void
usage(void)
{
(void)fprintf(stderr, "usage: dirname string\n");
(void)fprintf(stderr, "usage: dirname string [...]\n");
exit(1);
}