Skip to content

Commit

Permalink
util: portable tmpname that gives a full path on Windows
Browse files Browse the repository at this point in the history
Fixes #1058.
  • Loading branch information
hishamhm committed Jan 15, 2020
1 parent bb6b7da commit 2f9732e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/luarocks/core/util.lua
Expand Up @@ -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
Expand Down

0 comments on commit 2f9732e

Please sign in to comment.