From 6b923cc70451a8483700023119746289f705548d Mon Sep 17 00:00:00 2001 From: dvs1 Date: Sat, 19 Oct 2024 20:38:28 +1000 Subject: Make APT.exe status return more robust. Lua sucks at this. --- aataaj.lua | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/aataaj.lua b/aataaj.lua index 5cc9423..d5b081e 100755 --- a/aataaj.lua +++ b/aataaj.lua @@ -159,24 +159,22 @@ APT.exe = function(c) I'm getting 7168 or 0. No idea what the fuck that is. local ok, rslt, status = os.execute(s) ]] - local f = APT.readCmd(self.cmd, 'r') + local f = APT.readCmd(self.cmd .. '; echo "$?"', 'r') -- The last line will be the command's returned status, collect everything else in result. - self.status = '' -- Otherwise the result starts with 0. + self.status = tonumber(f[#f]) + f[#f] = nil self.result = '\n' self.lines = f for i,l in ipairs(f) do self.result = self.result .. l .. "\n" end - f = APT.readCmd('echo "$?"', 'r') - for i,l in ipairs(f) do - self.status = tonumber(l) - if (137 == self.status) or (124 == self.status) then - print("timeout killed " .. self.status .. ' ' .. self.command) - E("timeout killed " .. self.status .. ' ' .. self.command) - elseif (0 ~= self.status) then - print("status |" .. self.status .. '| ' .. self.command) - E("status |" .. self.status .. '| ' .. self.command) - end + if (137 == self.status) or (124 == self.status) then + print("timeout killed " .. self.status .. ' ' .. self.command) + print('ERROR ' .. "timeout killed " .. self.status .. ' ' .. self.command) + elseif (nil == self.status) then + print("STATUS |" .. "NIL" .. '| ' .. self.command) + elseif (0 ~= self.status) then + print("STATUS |" .. self.status .. '| ' .. self.command) end return self end -- cgit v1.1