commit ffb88123943eaa3bc84303049b5e24e130c8e749
parent 58f66ce4ce481106242ccbb6e39ac3d95d8edeb3
Author: phoebos <ben@bvnf.space>
Date: Mon, 31 Jul 2023 13:41:31 +0100
utils.capture: return nil if cmd failed
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/bliss/utils.lua b/bliss/utils.lua
@@ -269,13 +269,15 @@ function run_quiet(path, cmd, env, logfile)
end
end
--- Returns an array of lines printed by cmd
+-- If cmd fails, return nil. Otherwise, return an array of lines
+-- printed by cmd.
function capture(cmd)
local p = io.popen(cmd, "r")
local res = {}
for line in p:lines() do
table.insert(res, line)
end
+ if not p:close() then return nil end
return res
end