From 1e926698897866d89b4a54e28f0e15c08d08c7ee Mon Sep 17 00:00:00 2001 From: alfred Date: Sun, 14 Jan 2001 12:08:50 +0000 Subject: 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(-) (limited to 'bin/mkdir') diff --git a/bin/mkdir/mkdir.c b/bin/mkdir/mkdir.c index 6c61abf..596e09f 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); -- cgit v1.1