From 9b0c5b56d39e5a405804ea477a5210fdba378e00 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sun, 24 Jun 2018 19:14:17 -0300 Subject: fs: add execute_env: execute with environment variables --- src/luarocks/fs/lua.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 88fc31d9..8640b01a 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -89,6 +89,15 @@ function fs_lua.execute_quiet(command, ...) end end +function fs.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, ...)) +end + --- Checks if the given tool is available. -- The tool is executed using a flag, usually just to ask its version. -- @param tool_cmd string: The command to be used to check the tool's presence (e.g. hg in case of Mercurial) -- cgit v1.2.3-55-g6feb