[hackers] [sbase] [PATCH 3/5] mkdir: Fail on EEXIST with no -p flag

From: Michael Forney <mforney_AT_mforney.org>
Date: Wed, 14 Dec 2016 19:40:04 -0800

mkdir without the -p flag should only exit success if it actually made
the directory.
---
 mkdir.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/mkdir.c b/mkdir.c
index f5da527..3e32d90 100644
--- a/mkdir.c
+++ b/mkdir.c
_AT_@ -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);
-- 
2.11.0
Received on Thu Dec 15 2016 - 04:40:04 CET

This archive was generated by hypermail 2.3.0 : Thu Dec 15 2016 - 04:48:26 CET