mkdir: Fail on EEXIST with no -p flag

mkdir without the -p flag should only exit success if it actually made
the directory.
This commit is contained in:
Michael Forney 2016-12-14 19:40:04 -08:00 committed by Anselm R Garbe
parent 830ca05c25
commit e795946971

View File

@ -38,10 +38,9 @@ main(int argc, char *argv[])
if (pflag) {
if (mkdirp(*argv) < 0)
ret = 1;
} else if (mkdir(*argv, S_IRWXU | S_IRWXG | S_IRWXO) < 0 &&
errno != EEXIST) {
weprintf("mkdir %s:", *argv);
ret = 1;
} else if (mkdir(*argv, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
weprintf("mkdir %s:", *argv);
ret = 1;
}
if (mflag && chmod(*argv, mode) < 0) {
weprintf("chmod %s:", *argv);