diff options
author | rwatson <rwatson@FreeBSD.org> | 2009-02-02 11:19:56 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2009-02-02 11:19:56 +0000 |
commit | 0239a09bb66985e26ab825606c869e7d98a4857b (patch) | |
tree | 86a224c60b2071af07052364354d3375bd8e3f5f /usr.bin/dirname | |
parent | af5756126ea4abebdc1e1fedff024352d7afc9f1 (diff) | |
download | FreeBSD-src-0239a09bb66985e26ab825606c869e7d98a4857b.zip FreeBSD-src-0239a09bb66985e26ab825606c869e7d98a4857b.tar.gz |
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
Diffstat (limited to 'usr.bin/dirname')
-rw-r--r-- | usr.bin/dirname/dirname.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.bin/dirname/dirname.c b/usr.bin/dirname/dirname.c index 3018f2f..93b135d 100644 --- a/usr.bin/dirname/dirname.c +++ b/usr.bin/dirname/dirname.c @@ -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); } |