From 21dd0cccae5c6d72a1b181c2988a82371ceadebd Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 14 Jan 2020 21:41:56 -0300 Subject: util: portable tmpname that gives a full path on Windows Fixes #1058. --- src/luarocks/core/util.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/luarocks/core/util.lua b/src/luarocks/core/util.lua index bd50ca0b..dae8cfab 100644 --- a/src/luarocks/core/util.lua +++ b/src/luarocks/core/util.lua @@ -12,7 +12,10 @@ local require = nil -- May be used to read more, passing, for instance, "*a". -- @return string: the output of the program. function util.popen_read(cmd, spec) - local tmpfile = os.tmpname() + local dir_sep = package.config:sub(1, 1) + local tmpfile = (dir_sep == "\\") + and (os.getenv("TMP") .. "/luarocks-" .. tostring(math.floor(math.random() * 10000))) + or os.tmpname() os.execute(cmd .. " > " .. tmpfile) local fd = io.open(tmpfile, "rb") if not fd then -- cgit v1.2.3-55-g6feb