From c0fe94c4a6f8c82e6d85a3700bab0e74e4244c4d Mon Sep 17 00:00:00 2001 From: Sewbacca Date: Fri, 16 Feb 2024 18:50:33 +0100 Subject: fix: `build.install_command` doesn't execute on windows --- src/luarocks/fs/lua.lua | 12 ++++++------ src/luarocks/fs/win32.lua | 10 ++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index ec497f88..0805efd2 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -54,7 +54,7 @@ function fs_lua.is_writable(file) return result end -local function quote_args(command, ...) +function fs_lua.quote_args(command, ...) local out = { command } local args = pack(...) for i=1, args.n do @@ -74,7 +74,7 @@ end -- otherwise. function fs_lua.execute(command, ...) assert(type(command) == "string") - return fs.execute_string(quote_args(command, ...)) + return fs.execute_string(fs.quote_args(command, ...)) end --- Run the given command, quoting its arguments, silencing its output. @@ -88,19 +88,19 @@ end function fs_lua.execute_quiet(command, ...) assert(type(command) == "string") if cfg.verbose then -- omit silencing output - return fs.execute_string(quote_args(command, ...)) + return fs.execute_string(fs.quote_args(command, ...)) else - return fs.execute_string(fs.quiet(quote_args(command, ...))) + return fs.execute_string(fs.quiet(fs.quote_args(command, ...))) end end -function fs.execute_env(env, command, ...) +function fs_lua.execute_env(env, command, ...) assert(type(command) == "string") local envstr = {} for var, val in pairs(env) do table.insert(envstr, fs.export_cmd(var, val)) end - return fs.execute_string(table.concat(envstr, "\n") .. "\n" .. quote_args(command, ...)) + return fs.execute_string(table.concat(envstr, "\n") .. "\n" .. fs.quote_args(command, ...)) end local tool_available_cache = {} diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua index 6c49f447..1a35c3d4 100644 --- a/src/luarocks/fs/win32.lua +++ b/src/luarocks/fs/win32.lua @@ -35,6 +35,16 @@ function win32.quiet_stderr(cmd) return cmd.." 2> NUL" end +function win32.execute_env(env, command, ...) + assert(type(command) == "string") + local cmdstr = {} + for var, val in pairs(env) do + table.insert(cmdstr, fs.export_cmd(var, val)) + end + table.insert(cmdstr, fs.quote_args(command, ...)) + return fs.execute_string(table.concat(cmdstr, " & ")) +end + -- Split path into drive, root and the rest. -- Example: "c:\\hello\\world" becomes "c:" "\\" "hello\\world" -- if any part is missing from input, it becomes an empty string. -- cgit v1.2.3-55-g6feb