From 28ddb3cb1f23fc2f7a07b6ce5494f44894da4de7 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 17 Dec 2016 05:25:43 +0000 Subject: [PATCH] Ignore eventual / suffix in TMPDIR --- src/remote.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/remote.cc b/src/remote.cc index 138f56c6..c4d0cec0 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -480,10 +480,12 @@ void RemoteUI::set_ui_options(const Options& options) m_socket_watcher.events() |= FdEvents::Write; } -static const char* tmpdir() +static StringView tmpdir() { - if (const char* tmpdir = getenv("TMPDIR")) - return tmpdir; + StringView tmpdir = getenv("TMPDIR"); + if (not tmpdir.empty()) + return tmpdir.back() == '/' ? tmpdir.substr(0_byte, tmpdir.length()-1) + : tmpdir; return "/tmp"; }