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>
This commit is contained in:
Alfred Perlstein 2001-01-14 12:08:50 +00:00
parent 8b075ef933
commit c51117f58d

View File

@ -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);