Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrej Valek <andrej.valek@siemens.com>2021-06-25 08:45:35 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2021-10-08 22:02:56 +0300
commitecac9853f29dcb2e5e0d70c0effaae2cabeefabf (patch)
tree4c42081fafbd0964c32fcd4c91d075bc9596cbf4 /coreutils
parentb198e9aa934386531b2bc1fd0291ed3cc6beaf96 (diff)
mktemp: add --tmpdir option
Make mktemp more compatible with coreutils. - add "--tmpdir" option - add long variants for "d,q,u" options Note: Upstream ca-certificate update script started using this option. function old new delta .rodata 104179 104219 +40 mktemp_main 186 194 +8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 48/0) Total: 48 bytes Signed-off-by: Andrej Valek <andrej.valek@siemens.com> Signed-off-by: Peter Marko <peter.marko@siemens.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/mktemp.c16
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)
OPT_t = 1 << 2,
OPT_p = 1 << 3,
OPT_u = 1 << 4,
+ OPT_tmpdir = (1 << 5) * ENABLE_LONG_OPTS,
};
path = getenv("TMPDIR");
if (!path || path[0] == '\0')
path = "/tmp";
+#if ENABLE_LONG_OPTS
+ opts = getopt32long(argv, "^"
+ "dqtp:u"
+ "\0"
+ "?1" /* 1 arg max */,
+ "directory\0" No_argument "d"
+ "quiet\0" No_argument "q"
+ "dry-run\0" No_argument "u"
+ "tmpdir\0" Optional_argument "\xff"
+ , &path, &path
+ );
+#else
opts = getopt32(argv, "^" "dqtp:u" "\0" "?1"/*1 arg max*/, &path);
+#endif
chp = argv[optind];
if (!chp) {
@@ -95,7 +109,7 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv)
goto error;
}
#endif
- if (opts & (OPT_t|OPT_p))
+ if (opts & (OPT_t|OPT_p|OPT_tmpdir))
chp = concat_path_file(path, chp);
if (opts & OPT_u) {