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:
parent
a52e28c7dd
commit
75d7ed1ed6
@ -52,6 +52,7 @@
|
||||
.Op Ar ...
|
||||
.Nm dirname
|
||||
.Ar string
|
||||
.Op Ar ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user