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:
Robert Watson 2009-02-02 11:19:56 +00:00
parent a52e28c7dd
commit 75d7ed1ed6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=188006
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();
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 @@ void
usage(void)
{
(void)fprintf(stderr, "usage: dirname string\n");
(void)fprintf(stderr, "usage: dirname string [...]\n");
exit(1);
}