Skip to content

Commit

Permalink
Replaced os.execute with mkutils.execute
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-h21 committed Oct 23, 2019
1 parent 630bac0 commit 929a374
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
13 changes: 3 additions & 10 deletions make4ht-lib.lua
Expand Up @@ -58,7 +58,7 @@ Make.run_command = function(self,filename,s)
elseif type(command) == "string" then
local run = command % params
log:info("Execute: " .. run)
return os.execute(run)
return mkutils.execute(run)
end
return false, "parse_lg: Command is not string or function"
end
Expand Down Expand Up @@ -97,7 +97,7 @@ Make.image_convert = function(self, images)
elseif type(command) == "string" then
local c = command % p
log:info("Make4ht convert: "..c)
os.execute(c)
mkutils.execute(c)
end
break
end
Expand Down Expand Up @@ -177,14 +177,7 @@ Make.run = function(self)
log:warning (command .." can be executed only "..repetition .."x")
else
log:info("executing: " .. command)
local f = io.popen(command, "r")
local output = f:read("*all")
-- rc will contain return codes of the executed command
local rc = {f:close()}
-- the status code is on the third position
-- https://stackoverflow.com/a/14031974/2467963
local status = rc[3]
log:output(output)
local status = mkutils.execute(command)
table.insert(return_codes,{name=v.name,status=status})
end
else
Expand Down
14 changes: 14 additions & 0 deletions mkutils.lua
Expand Up @@ -226,6 +226,20 @@ function copy(filename,outfilename)
return true
end

function execute(command)
local f = io.popen(command, "r")
local output = f:read("*all")
-- rc will contain return codes of the executed command
local rc = {f:close()}
-- the status code is on the third position
-- https://stackoverflow.com/a/14031974/2467963
local status = rc[3]
-- print the command line output only when requested through
-- log level
log:output(output)
return status
end

-- find the zip command
function find_zip()
if io.popen("zip -v","r"):close() then
Expand Down

0 comments on commit 929a374

Please sign in to comment.