sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 91a643411d744bbdfe0b356b73463eaaf500e02a
parent a7b8eee6c091feda1f5dd6cdfb12a0d3249beebc
Author: sin <sin@2f30.org>
Date:   Thu, 14 Nov 2013 19:46:21 +0000

Check for TMPDIR and if set use it

Diffstat:
Mmktemp.c | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mktemp.c b/mktemp.c @@ -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; @@ -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)) {