summaryrefslogtreecommitdiffstats
path: root/bin/mkdir/mkdir.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/mkdir/mkdir.c')
-rw-r--r--bin/mkdir/mkdir.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/bin/mkdir/mkdir.c b/bin/mkdir/mkdir.c
index 89e9eba..84b05df 100644
--- a/bin/mkdir/mkdir.c
+++ b/bin/mkdir/mkdir.c
@@ -63,7 +63,7 @@ main(argc, argv)
int argc;
char *argv[];
{
- int ch, exitval, omode, pflag;
+ int ch, exitval, success, omode, pflag;
mode_t *set = (mode_t *)NULL;
char *mode;
@@ -96,13 +96,16 @@ main(argc, argv)
}
for (exitval = 0; *argv != NULL; ++argv) {
+ success = 1;
if (pflag) {
if (build(*argv, omode))
- exitval = 1;
+ success = 0;
} else if (mkdir(*argv, omode) < 0) {
warn("%s", *argv);
- exitval = 1;
+ success = 0;
}
+ if (!success)
+ exitval = 1;
/*
* The mkdir() and umask() calls both honor only the low
* nine bits, so if you try to set a mode including the
@@ -110,9 +113,8 @@ main(argc, argv)
* this unless the user has specifically requested a mode,
* as chmod will (obviously) ignore the umask.
*/
- if ((exitval == 0) &&
- (mode != NULL) && (chmod(*argv, omode) == -1)) {
- warn("chmod %s", *argv);
+ if (success && mode != NULL && chmod(*argv, omode) == -1) {
+ warn("%s", *argv);
exitval = 1;
}
}
OpenPOWER on IntegriCloud