diff options
author | msmith <msmith@FreeBSD.org> | 1998-10-23 06:28:40 +0000 |
---|---|---|
committer | msmith <msmith@FreeBSD.org> | 1998-10-23 06:28:40 +0000 |
commit | b63c54893fae250aab2ddcd654d6bd5e9fa31b34 (patch) | |
tree | 0ba41d398962d5b495138c378607ee09bb33ded7 /bin/mkdir | |
parent | b898ae170b41b12e66753bfa9f82eea9a5bb794e (diff) | |
download | FreeBSD-src-b63c54893fae250aab2ddcd654d6bd5e9fa31b34.zip FreeBSD-src-b63c54893fae250aab2ddcd654d6bd5e9fa31b34.tar.gz |
Fix behaviour for 'mkdir -m 777 / /tmp/foo'. Play "guess the style bug"
with Bruce again.
Reported by: bde
Diffstat (limited to 'bin/mkdir')
-rw-r--r-- | bin/mkdir/mkdir.c | 14 |
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; } } |