diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2018-06-24 19:14:17 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-07-01 15:51:35 -0300 |
| commit | 9b0c5b56d39e5a405804ea477a5210fdba378e00 (patch) | |
| tree | 871fe57553541c29d91ae0589d62a67a5019b179 /src | |
| parent | a1715807478ba5c2c16f8cf73eaf5f664aabdbcb (diff) | |
| download | luarocks-9b0c5b56d39e5a405804ea477a5210fdba378e00.tar.gz luarocks-9b0c5b56d39e5a405804ea477a5210fdba378e00.tar.bz2 luarocks-9b0c5b56d39e5a405804ea477a5210fdba378e00.zip | |
fs: add execute_env: execute with environment variables
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/fs/lua.lua | 9 |
1 files changed, 9 insertions, 0 deletions
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, ...) | |||
| 89 | end | 89 | end |
| 90 | end | 90 | end |
| 91 | 91 | ||
| 92 | function fs.execute_env(env, command, ...) | ||
| 93 | assert(type(command) == "string") | ||
| 94 | local envstr = {} | ||
| 95 | for var, val in pairs(env) do | ||
| 96 | table.insert(envstr, fs.export_cmd(var, val)) | ||
| 97 | end | ||
| 98 | return fs.execute_string(table.concat(envstr, "\n") .. "\n" .. quote_args(command, ...)) | ||
| 99 | end | ||
| 100 | |||
| 92 | --- Checks if the given tool is available. | 101 | --- Checks if the given tool is available. |
| 93 | -- The tool is executed using a flag, usually just to ask its version. | 102 | -- The tool is executed using a flag, usually just to ask its version. |
| 94 | -- @param tool_cmd string: The command to be used to check the tool's presence (e.g. hg in case of Mercurial) | 103 | -- @param tool_cmd string: The command to be used to check the tool's presence (e.g. hg in case of Mercurial) |
