diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-10-10 15:28:41 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-10-10 15:28:41 +0000 |
commit | 1ac42bf66e2c181b886e89f9222cae65676c9e8a (patch) | |
tree | a0170e61d7a3263e725c65fa83082ef6068a99da | |
parent | da8f43fd34d59a83ee8314dae5850db95ac1bdad (diff) | |
download | busybox-1ac42bf66e2c181b886e89f9222cae65676c9e8a.tar.gz |
- add option -t
mkinitrd and mkinitramfs both require -t.
-rw-r--r-- | debianutils/mktemp.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/debianutils/mktemp.c b/debianutils/mktemp.c index 546e030b0..d47d5a0bf 100644 --- a/debianutils/mktemp.c +++ b/debianutils/mktemp.c @@ -18,21 +18,31 @@ int mktemp_main(int argc, char **argv) { - unsigned long flags = getopt32(argc, argv, "dq"); + unsigned long flags = getopt32(argc, argv, "dqt"); + char *chp; if (optind + 1 != argc) bb_show_usage(); + chp = argv[optind]; + + if (flags & 4) { + char *dir = getenv("TMPDIR"); + if (dir && *dir != '\0') + chp = concat_path_file(dir, chp); + else + chp = concat_path_file("/tmp/", chp); + } + if (flags & 1) { - if (mkdtemp(argv[optind]) == NULL) + if (mkdtemp(chp) == NULL) return EXIT_FAILURE; - } - else { - if (mkstemp(argv[optind]) < 0) + } else { + if (mkstemp(chp) < 0) return EXIT_FAILURE; } - puts(argv[optind]); + puts(chp); return EXIT_SUCCESS; } |