# HG changeset patch # User Rob Landley # Date 1423780919 21600 # Node ID 1e0af8b8c8ec363c385c1d14add8f4fc12f8bf01 # Parent ed94226a879ed84a3b099ee1c404bb06a9e52b7c Fix bug introduced by last commit (print template instead of toybuf). Also, xstrdup() the unmodified template because changing the environment string could make the changed version show up in "ps". diff -r ed94226a879e -r 1e0af8b8c8ec toys/lsb/mktemp.c --- a/toys/lsb/mktemp.c Wed Feb 11 17:10:28 2015 -0600 +++ b/toys/lsb/mktemp.c Thu Feb 12 16:41:59 2015 -0600 @@ -40,11 +40,14 @@ if (!TT.tmpdir) TT.tmpdir = getenv("TMPDIR"); if (!TT.tmpdir) TT.tmpdir = "/tmp"; - if (!strchr(template, '/')) template = xmprintf("%s/%s", TT.tmpdir, template); + template = strchr(template, '/') ? xstrdup(template) + : xmprintf("%s/%s", TT.tmpdir, template); if (d_flag ? !mkdtemp(template) : mkstemp(template) == -1) { if (toys.optflags & FLAG_q) toys.exitval = 1; else perror_exit("Failed to create %s %s/%s", d_flag ? "directory" : "file", TT.tmpdir, template); - } else xputs(toybuf); + } else xputs(template); + + if (CFG_TOYBOX_FREE) free(template); }