diff options
-rw-r--r-- | coreutils/mktemp.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/coreutils/mktemp.c b/coreutils/mktemp.c index 5393320a5..33e2720de 100644 --- a/coreutils/mktemp.c +++ b/coreutils/mktemp.c | |||
@@ -72,13 +72,27 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv) | |||
72 | OPT_t = 1 << 2, | 72 | OPT_t = 1 << 2, |
73 | OPT_p = 1 << 3, | 73 | OPT_p = 1 << 3, |
74 | OPT_u = 1 << 4, | 74 | OPT_u = 1 << 4, |
75 | OPT_tmpdir = (1 << 5) * ENABLE_LONG_OPTS, | ||
75 | }; | 76 | }; |
76 | 77 | ||
77 | path = getenv("TMPDIR"); | 78 | path = getenv("TMPDIR"); |
78 | if (!path || path[0] == '\0') | 79 | if (!path || path[0] == '\0') |
79 | path = "/tmp"; | 80 | path = "/tmp"; |
80 | 81 | ||
82 | #if ENABLE_LONG_OPTS | ||
83 | opts = getopt32long(argv, "^" | ||
84 | "dqtp:u" | ||
85 | "\0" | ||
86 | "?1" /* 1 arg max */, | ||
87 | "directory\0" No_argument "d" | ||
88 | "quiet\0" No_argument "q" | ||
89 | "dry-run\0" No_argument "u" | ||
90 | "tmpdir\0" Optional_argument "\xff" | ||
91 | , &path, &path | ||
92 | ); | ||
93 | #else | ||
81 | opts = getopt32(argv, "^" "dqtp:u" "\0" "?1"/*1 arg max*/, &path); | 94 | opts = getopt32(argv, "^" "dqtp:u" "\0" "?1"/*1 arg max*/, &path); |
95 | #endif | ||
82 | 96 | ||
83 | chp = argv[optind]; | 97 | chp = argv[optind]; |
84 | if (!chp) { | 98 | if (!chp) { |
@@ -95,7 +109,7 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv) | |||
95 | goto error; | 109 | goto error; |
96 | } | 110 | } |
97 | #endif | 111 | #endif |
98 | if (opts & (OPT_t|OPT_p)) | 112 | if (opts & (OPT_t|OPT_p|OPT_tmpdir)) |
99 | chp = concat_path_file(path, chp); | 113 | chp = concat_path_file(path, chp); |
100 | 114 | ||
101 | if (opts & OPT_u) { | 115 | if (opts & OPT_u) { |