aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSewbacca <sewbacca@kolabnow.com>2024-02-16 18:50:33 +0100
committerHisham Muhammad <hisham@gobolinux.org>2024-02-16 19:34:02 -0300
commitc0fe94c4a6f8c82e6d85a3700bab0e74e4244c4d (patch)
treefd6a01b60e5cef2465e0818ea75dc644e36eaa5a
parentea43975308abc8b5281ac8934657aa4d59bcdd75 (diff)
downloadluarocks-c0fe94c4a6f8c82e6d85a3700bab0e74e4244c4d.tar.gz
luarocks-c0fe94c4a6f8c82e6d85a3700bab0e74e4244c4d.tar.bz2
luarocks-c0fe94c4a6f8c82e6d85a3700bab0e74e4244c4d.zip
fix: `build.install_command` doesn't execute on windows
-rw-r--r--src/luarocks/fs/lua.lua12
-rw-r--r--src/luarocks/fs/win32.lua10
2 files changed, 16 insertions, 6 deletions
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)
54 return result 54 return result
55end 55end
56 56
57local function quote_args(command, ...) 57function fs_lua.quote_args(command, ...)
58 local out = { command } 58 local out = { command }
59 local args = pack(...) 59 local args = pack(...)
60 for i=1, args.n do 60 for i=1, args.n do
@@ -74,7 +74,7 @@ end
74-- otherwise. 74-- otherwise.
75function fs_lua.execute(command, ...) 75function fs_lua.execute(command, ...)
76 assert(type(command) == "string") 76 assert(type(command) == "string")
77 return fs.execute_string(quote_args(command, ...)) 77 return fs.execute_string(fs.quote_args(command, ...))
78end 78end
79 79
80--- Run the given command, quoting its arguments, silencing its output. 80--- Run the given command, quoting its arguments, silencing its output.
@@ -88,19 +88,19 @@ end
88function fs_lua.execute_quiet(command, ...) 88function fs_lua.execute_quiet(command, ...)
89 assert(type(command) == "string") 89 assert(type(command) == "string")
90 if cfg.verbose then -- omit silencing output 90 if cfg.verbose then -- omit silencing output
91 return fs.execute_string(quote_args(command, ...)) 91 return fs.execute_string(fs.quote_args(command, ...))
92 else 92 else
93 return fs.execute_string(fs.quiet(quote_args(command, ...))) 93 return fs.execute_string(fs.quiet(fs.quote_args(command, ...)))
94 end 94 end
95end 95end
96 96
97function fs.execute_env(env, command, ...) 97function fs_lua.execute_env(env, command, ...)
98 assert(type(command) == "string") 98 assert(type(command) == "string")
99 local envstr = {} 99 local envstr = {}
100 for var, val in pairs(env) do 100 for var, val in pairs(env) do
101 table.insert(envstr, fs.export_cmd(var, val)) 101 table.insert(envstr, fs.export_cmd(var, val))
102 end 102 end
103 return fs.execute_string(table.concat(envstr, "\n") .. "\n" .. quote_args(command, ...)) 103 return fs.execute_string(table.concat(envstr, "\n") .. "\n" .. fs.quote_args(command, ...))
104end 104end
105 105
106local tool_available_cache = {} 106local 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)
35 return cmd.." 2> NUL" 35 return cmd.." 2> NUL"
36end 36end
37 37
38function win32.execute_env(env, command, ...)
39 assert(type(command) == "string")
40 local cmdstr = {}
41 for var, val in pairs(env) do
42 table.insert(cmdstr, fs.export_cmd(var, val))
43 end
44 table.insert(cmdstr, fs.quote_args(command, ...))
45 return fs.execute_string(table.concat(cmdstr, " & "))
46end
47
38-- Split path into drive, root and the rest. 48-- Split path into drive, root and the rest.
39-- Example: "c:\\hello\\world" becomes "c:" "\\" "hello\\world" 49-- Example: "c:\\hello\\world" becomes "c:" "\\" "hello\\world"
40-- if any part is missing from input, it becomes an empty string. 50-- if any part is missing from input, it becomes an empty string.