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
af5756126e
commit
0239a09bb6
@ -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();
|
||||
|
||||
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