Hi,
I'm forwarding a patch from Timo Teräs that provides -p option for
mktemp as in the coreutils version.
This is needed for making busybox mktemp work with util-vserver scripts
for example.
Thanks!
-nc
--- Begin Message ---
patch attached
Index: debianutils/mktemp.c
===================================================================
--- debianutils/mktemp.c (revision 20945)
+++ debianutils/mktemp.c (working copy)
@@ -14,7 +14,8 @@
int mktemp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int mktemp_main(int argc, char **argv)
{
- unsigned long flags = getopt32(argv, "dqt");
+ char *path = NULL;
+ unsigned long flags = getopt32(argv, "dqtp:", &path);
char *chp;
if (optind + 1 != argc)
@@ -22,10 +23,12 @@
chp = argv[optind];
- if (flags & 4) {
+ if ((flags & 4) || path) {
char *dir = getenv("TMPDIR");
if (dir && *dir != '\0')
chp = concat_path_file(dir, chp);
+ else if (path)
+ chp = concat_path_file(path, chp);
else
chp = concat_path_file("/tmp/", chp);
}
Index: include/usage.h
===================================================================
--- include/usage.h (revision 20945)
+++ include/usage.h (working copy)
@@ -2323,13 +2323,21 @@
" block-count Number of block to use (default is entire partition)"
#define mktemp_trivial_usage \
- "[-dq] TEMPLATE"
+ "[-dqt] [-p dir] TEMPLATE"
#define mktemp_full_usage \
"Create a temporary file with its name based on TEMPLATE.\n" \
"TEMPLATE is any name with six 'Xs' (i.e., /tmp/temp.XXXXXX)." \
"\n\nOptions:\n" \
" -d Make a directory instead of a file\n" \
- " -q Fail silently if an error occurs"
+ " -q Fail silently if an error occurs\n" \
+ " -t Generate a path rooted in temporary directory\n" \
+ " -p DIR Use DIR as a temporary directory (implies -t)\n" \
+ "\n" \
+ "If -t (or -p) is specified, the temporary directory is chosen as follows:\n" \
+ " 1. if environment variable $TMPDIR is set, it is used\n" \
+ " 2. if directory is provided with -p, it is used\n" \
+ " 3. /tmp is used"
+
#define mktemp_example_usage \
"$ mktemp /tmp/temp.XXXXXX\n" \
"/tmp/temp.mWiLjM\n" \
--- End Message ---
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox