Add simple rerun option
This commit is contained in:
parent
e02c78e1b5
commit
bd860dd5a2
@ -19,7 +19,7 @@ do
|
||||
for _, a in ipairs(arg) do
|
||||
local name, value = arg_pattern:match(a)
|
||||
if name then
|
||||
arg[name] = value
|
||||
arg[name] = math.tointeger(value) or value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -4,6 +4,7 @@ local ourname = arg[0] -- This might not be os.selfarg[0]
|
||||
if os.selfarg[0] == ourname then
|
||||
ourname = nil
|
||||
end
|
||||
local run
|
||||
for i, a in ipairs(os.selfarg) do
|
||||
if a == ourname then -- Avoid recursion
|
||||
table.remove(os.selfarg, i)
|
||||
@ -18,6 +19,9 @@ for i, a in ipairs(os.selfarg) do
|
||||
if a:sub(1, 11) == "--progname=" then
|
||||
format = a:sub(12)
|
||||
end
|
||||
if a:sub(1, 6) == "--run=" then
|
||||
run = true
|
||||
end
|
||||
end
|
||||
os.setenv("engine", status.luatex_engine)
|
||||
local kpse_call = io.popen(string.format("kpsewhich -progname %s -format lua -all -must-exist %s-init.lua", format, format))
|
||||
@ -28,5 +32,23 @@ until not file:match('^%.')
|
||||
if not kpse_call:close() then
|
||||
error(file)
|
||||
end
|
||||
|
||||
local geterrorcode
|
||||
if os.type == 'windows' then
|
||||
function geterrorcode(ec) return ec end
|
||||
else
|
||||
function geterrorcode(ec) return ec & 0xFF == 0 and ec >> 8 or 0xFF end
|
||||
end
|
||||
|
||||
local args = os.selfarg[1] and " \"" .. table.concat(os.selfarg, "\" \"") .. "\"" or ""
|
||||
os.exit(os.execute(string.format("luametatex \"--lua=%s\" --arg0=\"%s\"%s", file, os.selfarg[0], args)))
|
||||
if run then -- The user wants to take care of it
|
||||
os.exit(geterrorcode(os.execute(string.format("luametatex \"--lua=%s\" --arg0=\"%s\"%s", file, os.selfarg[0], args))))
|
||||
else
|
||||
for i = 1, 5 do
|
||||
local status = geterrorcode(os.execute(string.format("luametatex \"--lua=%s\" --arg0=\"%s\" --run=%i%s", file, os.selfarg[0], i, args)))
|
||||
if status ~= 75 then
|
||||
os.exit(status)
|
||||
end
|
||||
end
|
||||
os.exit(75)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user