← Commit list

9b814ca63

Denys Vlasenko
Denys Vlasenko
2010-06-18
FAILED Duration: 33s

Subject

mktemp: be more compatible: bare "mktemp" creates tempfile in /tmp, not cwd

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

debianutils/mktemp.c+10 -13
@@ -39,23 +39,20 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv)
{
const char *path;
char *chp;
- unsigned opt;
+ unsigned opts;
+ path = getenv("TMPDIR");
+ if (!path || path[0] == '\0')
+ path = "/tmp";
+
+ /* -q and -t are ignored */
opt_complementary = "?1"; /* 1 argument max */
- opt = getopt32(argv, "dqtp:", &path);
- chp = argv[optind] ? argv[optind] : xstrdup("tmp.XXXXXX");
+ opts = getopt32(argv, "dqtp:", &path);
- if (opt & (4|8)) { /* -t and/or -p */
- const char *dir = getenv("TMPDIR");
- if (dir && *dir != '\0')
- path = dir;
- else if (!(opt & 8)) /* no -p */
- path = "/tmp/";
- /* else path comes from -p DIR */
- chp = concat_path_file(path, chp);
- }
+ chp = argv[optind] ? argv[optind] : xstrdup("tmp.XXXXXX");
+ chp = concat_path_file(path, chp);
- if (opt & 1) { /* -d */
+ if (opts & 1) { /* -d */
if (mkdtemp(chp) == NULL)
return EXIT_FAILURE;
} else {