[hackers] [sbase] Check for TMPDIR and if set use it || sin

From: <git_AT_suckless.org>
Date: Thu, 14 Nov 2013 20:47:27 +0100

commit 91a643411d744bbdfe0b356b73463eaaf500e02a
Author: sin <sin_AT_2f30.org>
Date: Thu Nov 14 19:46:21 2013 +0000

    Check for TMPDIR and if set use it

diff --git a/mktemp.c b/mktemp.c
index f5a0be5..8416a01 100644
--- a/mktemp.c
+++ b/mktemp.c
_AT_@ -19,7 +19,7 @@ int
 main(int argc, char *argv[])
 {
         char *template = "tmp.XXXXXXXXXX";
- char *tmpdir = "/tmp";
+ char *tmpdir = "/tmp", *p;
         char tmppath[PATH_MAX];
         int fd;
 
_AT_@ -39,6 +39,9 @@ main(int argc, char *argv[])
         else if (argc == 1)
                 template = argv[0];
 
+ if ((p = getenv("TMPDIR")))
+ tmpdir = p;
+
         snprintf(tmppath, sizeof(tmppath), "%s/%s", tmpdir, template);
         if (dflag) {
                 if (!mkdtemp(tmppath)) {
Received on Thu Nov 14 2013 - 20:47:27 CET

This archive was generated by hypermail 2.3.0 : Thu Nov 14 2013 - 20:48:14 CET