Ignore eventual / suffix in TMPDIR

This commit is contained in:
Maxime Coste 2016-12-17 05:25:43 +00:00
parent d8620b9e79
commit 28ddb3cb1f

View File

@ -480,10 +480,12 @@ void RemoteUI::set_ui_options(const Options& options)
m_socket_watcher.events() |= FdEvents::Write; m_socket_watcher.events() |= FdEvents::Write;
} }
static const char* tmpdir() static StringView tmpdir()
{ {
if (const char* tmpdir = getenv("TMPDIR")) StringView tmpdir = getenv("TMPDIR");
return tmpdir; if (not tmpdir.empty())
return tmpdir.back() == '/' ? tmpdir.substr(0_byte, tmpdir.length()-1)
: tmpdir;
return "/tmp"; return "/tmp";
} }