diff options
author | Robert Watson <rwatson@FreeBSD.org> | 2009-02-02 11:19:56 +0000 |
---|---|---|
committer | Robert Watson <rwatson@FreeBSD.org> | 2009-02-02 11:19:56 +0000 |
commit | 75d7ed1ed67d0a5ed993f5ed9bcd661dd17f1b84 (patch) | |
tree | 86a224c60b2071af07052364354d3375bd8e3f5f /usr.bin/dirname/dirname.c | |
parent | a52e28c7dd4bce1a0a9374f8860bda6d5784b1b0 (diff) |
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
Notes
Notes:
svn path=/head/; revision=188006
Diffstat (limited to 'usr.bin/dirname/dirname.c')
-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 3018f2f6f00c..93b135de2167 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); } |