summaryrefslogtreecommitdiffstats
path: root/bin/mkdir/mkdir.c
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2001-01-14 12:08:50 +0000
committeralfred <alfred@FreeBSD.org>2001-01-14 12:08:50 +0000
commit1e926698897866d89b4a54e28f0e15c08d08c7ee (patch)
tree5aa33bdf6ae6a2e362081f042e77a91b4292d736 /bin/mkdir/mkdir.c
parentffc1b6907f69a0ba44c97ce1d8d153adac60473d (diff)
downloadFreeBSD-src-1e926698897866d89b4a54e28f0e15c08d08c7ee.zip
FreeBSD-src-1e926698897866d89b4a54e28f0e15c08d08c7ee.tar.gz
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 <whs@xs4all.nl>
Diffstat (limited to 'bin/mkdir/mkdir.c')
-rw-r--r--bin/mkdir/mkdir.c6
1 files changed, 5 insertions, 1 deletions
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 <err.h>
#include <errno.h>
+#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -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);
OpenPOWER on IntegriCloud