From 4cb6e07eff50cdac3f7749db23fbc6e2027d314f Mon Sep 17 00:00:00 2001 From: des Date: Wed, 6 Sep 2000 07:28:02 +0000 Subject: Reintroduce functionality and error checks that were boneheadedly removed in the previous commit. Pass me the pointy hat. PR: bin/21061 --- usr.bin/dirname/dirname.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'usr.bin/dirname') diff --git a/usr.bin/dirname/dirname.c b/usr.bin/dirname/dirname.c index cb5adbd..f9d3e3d 100644 --- a/usr.bin/dirname/dirname.c +++ b/usr.bin/dirname/dirname.c @@ -43,6 +43,7 @@ static const char copyright[] = static const char sccsid[] = "@(#)dirname.c 8.4 (Berkeley) 5/4/95"; #endif /* not lint */ +#include #include #include #include @@ -54,6 +55,7 @@ main(argc, argv) int argc; char **argv; { + char *p; int ch; while ((ch = getopt(argc, argv, "")) != -1) @@ -68,7 +70,9 @@ main(argc, argv) if (argc != 1) usage(); - (void)printf("%s\n", dirname(*argv)); + if ((p = dirname(*argv)) == NULL) + err(1, "%s", *argv); + (void)printf("%s\n", p); exit(0); } -- cgit v1.1