]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
mktemp: synchronize the -p option with docs
authorPádraig Brady <P@draigBrady.com>
Sat, 21 Sep 2013 02:33:12 +0000 (03:33 +0100)
committerPádraig Brady <P@draigBrady.com>
Sun, 6 Oct 2013 16:59:00 +0000 (17:59 +0100)
* src/mktemp.c (usage): Synchronize the -p option description with
the logic and info docs.  I.E. that -p is just an alias of --tmpdir.
Also for consistency treat --tmpdir='' the same with or without -t.
I.E. always ignore the --tmpdir option if the param is empty.
Fixes http://bugs.gnu.org/15425

src/mktemp.c

index 44845c33f50c073d875bb50148f044413a7b66d8..41d576306055c715b8586b5a867cf5b18c1725f1 100644 (file)
@@ -43,7 +43,6 @@ static const char *default_template = "tmp.XXXXXXXXXX";
 enum
 {
   SUFFIX_OPTION = CHAR_MAX + 1,
-  TMPDIR_OPTION
 };
 
 static struct option const longopts[] =
@@ -52,7 +51,7 @@ static struct option const longopts[] =
   {"quiet", no_argument, NULL, 'q'},
   {"dry-run", no_argument, NULL, 'u'},
   {"suffix", required_argument, NULL, SUFFIX_OPTION},
-  {"tmpdir", optional_argument, NULL, TMPDIR_OPTION},
+  {"tmpdir", optional_argument, NULL, 'p'},
   {GETOPT_HELP_OPTION_DECL},
   {GETOPT_VERSION_OPTION_DECL},
   {NULL, 0, NULL, 0}
@@ -85,20 +84,17 @@ Files are created u+rw, and directories u+rwx, minus umask restrictions.\n\
                         This option is implied if TEMPLATE does not end in X\n\
 "), stdout);
       fputs (_("\
-      --tmpdir[=DIR]  interpret TEMPLATE relative to DIR; if DIR is not\n\
+  -p DIR, --tmpdir[=DIR]  interpret TEMPLATE relative to DIR; if DIR is not\n\
                         specified, use $TMPDIR if set, else /tmp.  With\n\
                         this option, TEMPLATE must not be an absolute name;\n\
                         unlike with -t, TEMPLATE may contain slashes, but\n\
                         mktemp creates only the final component\n\
 "), stdout);
-      fputs ("\n", stdout);
       fputs (_("\
-  -p DIR              use DIR as a prefix; implies -t [deprecated]\n\
   -t                  interpret TEMPLATE as a single file name component,\n\
                         relative to a directory: $TMPDIR, if set; else the\n\
                         directory specified via -p; else /tmp [deprecated]\n\
 "), stdout);
-      fputs ("\n", stdout);
       fputs (HELP_OPTION_DESCRIPTION, stdout);
       fputs (VERSION_OPTION_DESCRIPTION, stdout);
       emit_ancillary_info ();
@@ -195,11 +191,6 @@ main (int argc, char **argv)
           dry_run = true;
           break;
 
-        case TMPDIR_OPTION:
-          use_dest_dir = true;
-          dest_dir_arg = optarg;
-          break;
-
         case SUFFIX_OPTION:
           suffix = optarg;
           break;
@@ -283,9 +274,12 @@ main (int argc, char **argv)
       if (deprecated_t_option)
         {
           char *env = getenv ("TMPDIR");
-          dest_dir = (env && *env
-                      ? env
-                      : (dest_dir_arg ? dest_dir_arg : "/tmp"));
+          if (env && *env)
+            dest_dir = env;
+          else if (dest_dir_arg && *dest_dir_arg)
+            dest_dir = dest_dir_arg;
+          else
+            dest_dir = "/tmp";
 
           if (last_component (template) != template)
             error (EXIT_FAILURE, 0,