From 8e67c2dec1a595619d540bc3e52c2dfcf61a63a3 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Sat, 21 Sep 2013 03:33:12 +0100 Subject: mktemp: synchronize the -p option with docs * 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 | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/mktemp.c b/src/mktemp.c index 44845c33f..41d576306 100644 --- a/src/mktemp.c +++ b/src/mktemp.c @@ -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, -- cgit v1.2.3-70-g09d2