[hackers] [sbase] mkdir: Fail on EEXIST with no -p flag || Michael Forney

From: <git_AT_suckless.org>
Date: Mon, 3 Jul 2017 21:06:19 +0200 (CEST)

commit e795946971f08b80ce9518088e590afa64bf0179
Author: Michael Forney <mforney_AT_mforney.org>
AuthorDate: Wed Dec 14 19:40:04 2016 -0800
Commit: Anselm R Garbe <anselm_AT_garbe.us>
CommitDate: Mon Jul 3 21:03:07 2017 +0200

    mkdir: Fail on EEXIST with no -p flag
    
    mkdir without the -p flag should only exit success if it actually made
    the directory.

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);
Received on Mon Jul 03 2017 - 21:06:19 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 03 2017 - 21:12:48 CEST