[hackers] [sbase] Add mandoc-manpage for mkdir(1) and clean up code || FRIGN

From: <git_AT_suckless.org>
Date: Tue, 24 Mar 2015 23:53:18 +0100 (CET)

commit 58dac5cf0abd4a354ff38d9beb542838447ff0a4
Author: FRIGN <dev_AT_frign.de>
Date: Mon Jan 26 15:30:56 2015 +0100

    Add mandoc-manpage for mkdir(1) and clean up code
    
    and mark it as finished in the README.

diff --git a/README b/README
index 5d9b77d..dab73bc 100644
--- a/README
+++ b/README
_AT_@ -42,7 +42,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support,
 =* logname yes none
 = ls no -C, -R, -q, -u
    md5sum non-posix none
-= mkdir yes none
+=* mkdir yes none
 = mkfifo yes none
 = mktemp non-posix none
 = mv yes (-i)
diff --git a/mkdir.1 b/mkdir.1
index 31d1728..2dd1b66 100644
--- a/mkdir.1
+++ b/mkdir.1
_AT_@ -1,19 +1,35 @@
-.TH MKDIR 1 sbase\-VERSION
-.SH NAME
-mkdir \- make directory
-.SH SYNOPSIS
-.B mkdir
-.RB [ \-pm ]
-.RI [ name ...]
-.SH DESCRIPTION
-.B mkdir
-creates the specified directories.
-.SH OPTIONS
-.TP
-.B \-p
-creates any necessary parent directories, and does not fail if the target
+.Dd January 26, 2015
+.Dt MKDIR 1 sbase\-VERSION
+.Sh NAME
+.Nm mkdir
+.Nd create directories
+.Sh SYNOPSIS
+.Nm mkdir
+.Op Fl p
+.Op Fl m Ar mode
+.Ar name ...
+.Sh DESCRIPTION
+.Nm
+creates a directory for each
+.Ar name
+if it does not already exist.
+.Sh OPTIONS
+.Bl -tag -width Ds
+.It Fl m
+Set the file
+.Ar mode
+of newly created directories.
+.It Fl p
+Also create necessary parent directories and
+do not fail if
+.Ar name
 already exists.
-.B \-m
-set the file permission bits of the newly created directory.
-.SH SEE ALSO
-.IR mkdir (2)
+.El
+.Sh SEE ALSO
+.Xr mkdir 2
+.Sh STANDARDS
+The
+.Nm
+utility is compliant with the
+.St -p1003.1-2008
+specification.
diff --git a/mkdir.c b/mkdir.c
index 536180c..a64051a 100644
--- a/mkdir.c
+++ b/mkdir.c
_AT_@ -8,7 +8,20 @@
 
 #include "util.h"
 
-static void mkdirp(char *);
+static void
+mkdirp(char *path)
+{
+ char *p = path;
+
+ do {
+ if (*p && (p = strchr(&p[1], '/')))
+ *p = '\0';
+ if (mkdir(path, S_IRWXU|S_IRWXG|S_IRWXO) < 0 && errno != EEXIST)
+ eprintf("mkdir %s:", path);
+ if (p)
+ *p = '/';
+ } while (p);
+}
 
 static void
 usage(void)
_AT_@ -51,18 +64,3 @@ main(int argc, char *argv[])
 
         return 0;
 }
-
-static void
-mkdirp(char *path)
-{
- char *p = path;
-
- do {
- if (*p && (p = strchr(&p[1], '/')))
- *p = '\0';
- if (mkdir(path, S_IRWXU|S_IRWXG|S_IRWXO) < 0 && errno != EEXIST)
- eprintf("mkdir %s:", path);
- if (p)
- *p = '/';
- } while (p);
-}
Received on Tue Mar 24 2015 - 23:53:18 CET

This archive was generated by hypermail 2.3.0 : Wed Mar 25 2015 - 00:03:32 CET