diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2011-09-30 11:56:43 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2013-12-16 13:39:46 +0000 |
commit | 516a6ecd6c5b627d351b3594e97121369f1f3ced (patch) | |
tree | 08eccea3640ca9aec860894a59d82aa705431f61 | |
parent | 6154adbc888a9912a434dc50bfeb5d9ecc3889cb (diff) | |
download | lua-aports-516a6ecd6c5b627d351b3594e97121369f1f3ced.tar.bz2 lua-aports-516a6ecd6c5b627d351b3594e97121369f1f3ced.tar.xz |
aports.lua: try get vars from env var before parsing abuild.conf
-rwxr-xr-x | aports.lua | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -5,11 +5,21 @@ abuild_conf_file = "/etc/abuild.conf" local abuild_conf = {} function get_abuild_conf(var) - if abuild_conf[var] == nil then - local f = io.popen(" . "..abuild_conf_file..' ; echo -n "$'..var..'"') - abuild_conf[var] = f:read("*all") - f:close() + -- check cache + if abuild_conf[var] ~= nil then + return abuild_conf[var] end + + -- use os env var + abuild_conf[var] = os.getenv(var) + if abuild_conf[var] ~= nil then + return abuild_conf[var] + end + + -- parse config file + local f = io.popen(" . "..abuild_conf_file..' ; echo -n "$'..var..'"') + abuild_conf[var] = f:read("*all") + f:close() return abuild_conf[var] end |