implemented numeric sort (sort -g)
[oweals/busybox.git] / mkdir.c
diff --git a/mkdir.c b/mkdir.c
index 0d0a90ec3d714dc0d4664f2bd776778a2c1175cb..9ea3b4ea0905d96e8e8c3721e6ee8f26631c68b8 100644 (file)
--- a/mkdir.c
+++ b/mkdir.c
 #include <errno.h>
 #include <sys/param.h>
 
-static const char mkdir_usage[] = "Usage: mkdir [OPTION] DIRECTORY...\n"
+static const char mkdir_usage[] = "Usage: mkdir [OPTION] DIRECTORY...\n\n"
 "Create the DIRECTORY(ies), if they do not already exist\n\n"
-"-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n"
-"-p\tno error if existing, make parent directories as needed\n";
+"Options:\n"
+"\t-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n"
+"\t-p\tno error if existing, make parent directories as needed\n";
 
 
 static int parentFlag = FALSE;
-static mode_t mode = 777;
+static mode_t mode = 0777;
 
 
 extern int mkdir_main(int argc, char **argv)
@@ -79,16 +80,21 @@ extern int mkdir_main(int argc, char **argv)
     while (argc > 0) {
        int status;
        struct stat statBuf;
-       status=stat(*argv, &statBuf);
+       char buf[NAME_MAX];
+
+       strcpy (buf, *argv);
+       status=stat(buf, &statBuf);
        if (status != -1 && status != ENOENT ) {
-           fprintf(stderr, "%s: File exists\n", *argv);
+           fprintf(stderr, "%s: File exists\n", buf);
            exit( FALSE);
        }
-       if (parentFlag == TRUE)
-           createPath(*argv, mode);
+       if (parentFlag == TRUE) {
+           strcat( buf, "/");
+           createPath(buf, mode);
+       }
        else { 
-           if (mkdir (*argv, mode) != 0) {
-               perror(*argv);
+           if (mkdir (buf, mode) != 0) {
+               perror(buf);
                exit( FALSE);
            }
        }