From c51117f58d8803c7acec0b3274195d55566ae1c9 Mon Sep 17 00:00:00 2001 From: Alfred Perlstein Date: Sun, 14 Jan 2001 12:08:50 +0000 Subject: [PATCH] Special case the error reporting when errno is ENOTDIR or ENOENT. This makes "mkdir /nonexistant/foo" complain that /nonexistant doesn't exist rather than /nonexistant/foo which doesn't make much sense. Submitted (in a different form) by: W.H.Scholten --- bin/mkdir/mkdir.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/mkdir/mkdir.c b/bin/mkdir/mkdir.c index 6c61abff5f14..596e09f80cd3 100644 --- a/bin/mkdir/mkdir.c +++ b/bin/mkdir/mkdir.c @@ -50,6 +50,7 @@ static const char rcsid[] = #include #include +#include #include #include #include @@ -108,7 +109,10 @@ main(argc, argv) if (build(*argv, omode)) success = 0; } else if (mkdir(*argv, omode) < 0) { - warn("%s", *argv); + if (errno == ENOTDIR || errno == ENOENT) + warn("%s", dirname(*argv)); + else + warn("%s", *argv); success = 0; } else if (vflag) (void)printf("%s\n", *argv);