diff options
author | dvs1 | 2024-10-20 10:28:44 +1000 |
---|---|---|
committer | dvs1 | 2024-10-20 10:28:44 +1000 |
commit | 4444c53df7dafb1271ab3f0196e2f133f0166c2c (patch) | |
tree | 4d0054db3a44e86d76944790008dd8e87aea8df2 | |
parent | Don't poke at HTTPS for URLsanity if the server doesn't actually support HTTPS. (diff) | |
download | apt-panopticon-4444c53df7dafb1271ab3f0196e2f133f0166c2c.zip apt-panopticon-4444c53df7dafb1271ab3f0196e2f133f0166c2c.tar.gz apt-panopticon-4444c53df7dafb1271ab3f0196e2f133f0166c2c.tar.bz2 apt-panopticon-4444c53df7dafb1271ab3f0196e2f133f0166c2c.tar.xz |
Tweak APT.exe a bit, more reliable return status.
Coz Lua really sucks at this. lol
-rw-r--r-- | apt-panopticommon.lua | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/apt-panopticommon.lua b/apt-panopticommon.lua index e31c22f..0939c3a 100644 --- a/apt-panopticommon.lua +++ b/apt-panopticommon.lua | |||
@@ -501,6 +501,8 @@ APT.readCmd = function(cmd) | |||
501 | table.insert(result, l) | 501 | table.insert(result, l) |
502 | end | 502 | end |
503 | end | 503 | end |
504 | -- While this does return the same things as os.execute(), it's just as useless. | ||
505 | output:close() | ||
504 | return result | 506 | return result |
505 | end | 507 | end |
506 | 508 | ||
@@ -590,23 +592,23 @@ APT.exe = function(c) | |||
590 | I'm getting 7168 or 0. No idea what the fuck that is. | 592 | I'm getting 7168 or 0. No idea what the fuck that is. |
591 | local ok, rslt, status = os.execute(s) | 593 | local ok, rslt, status = os.execute(s) |
592 | ]] | 594 | ]] |
593 | local f = APT.readCmd(self.cmd, 'r') | 595 | local f = APT.readCmd(self.cmd .. '; echo "$?"', 'r') |
594 | -- The last line will be the command's returned status, collect everything else in result. | 596 | -- The last line will be the command's returned status, collect everything else in result. |
595 | self.status = '' -- Otherwise the result starts with 0. | 597 | self.status = tonumber(f[#f]) |
598 | f[#f] = nil | ||
596 | self.result = '\n' | 599 | self.result = '\n' |
597 | for i,l in ipairs(f) do | 600 | for i,l in ipairs(f) do |
598 | self.result = self.result .. l .. "\n" | 601 | self.result = self.result .. l .. "\n" |
599 | end | 602 | end |
600 | f = APT.readCmd('echo "$?"', 'r') | 603 | if (137 == self.status) or (124 == self.status) then |
601 | for i,l in ipairs(f) do | 604 | print("timeout killed " .. self.status .. ' ' .. self.command) |
602 | self.status = tonumber(l) | 605 | print('ERROR ' .. "timeout killed " .. self.status .. ' ' .. self.command) |
603 | if (137 == self.status) or (124 == self.status) then | 606 | elseif (nil == self.status) then |
604 | print("timeout killed " .. self.status .. ' ' .. self.command) | 607 | print("status |" .. "NIL" .. '| ' .. self.command) |
605 | E("timeout killed " .. self.status .. ' ' .. self.command) | 608 | E("status |" .. "NIL" .. '| ' .. self.command) |
606 | elseif (0 ~= self.status) then | 609 | elseif (0 ~= self.status) then |
607 | print("status |" .. self.status .. '| ' .. self.command) | 610 | -- print("status |" .. self.status .. '| ' .. self.command) |
608 | E("status |" .. self.status .. '| ' .. self.command) | 611 | E("status |" .. self.status .. '| ' .. self.command) |
609 | end | ||
610 | end | 612 | end |
611 | return self | 613 | return self |
612 | end | 614 | end |