summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/luat-exe.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/luat-exe.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/luat-exe.lua91
1 files changed, 59 insertions, 32 deletions
diff --git a/Master/texmf-dist/tex/context/base/luat-exe.lua b/Master/texmf-dist/tex/context/base/luat-exe.lua
index ca3b751623b..42c17ded58d 100644
--- a/Master/texmf-dist/tex/context/base/luat-exe.lua
+++ b/Master/texmf-dist/tex/context/base/luat-exe.lua
@@ -6,66 +6,93 @@ if not modules then modules = { } end modules ['luat-exe'] = {
license = "see context related readme files"
}
-local match, find = string.match, string.find
+-- this module needs checking (very old and never really used, not even enabled)
+
+local match, find, gmatch = string.match, string.find, string.gmatch
local concat = table.concat
-if not executer then executer = { } end
+local report_executers = logs.reporter("system","executers")
+
+resolvers.executers = resolvers.executers or { }
+local executers = resolvers.executers
-executer.permitted = { }
-executer.execute = os.execute
+local permitted = { }
+local osexecute = os.execute
+local execute = osexecute
-function executer.register(...)
- local ep = executer.permitted
+local function register(...)
local t = { ... }
for k=1,#t do
local v = t[k]
- ep[#ep+1] = (v == "*" and ".*") or v
+ permitted[#permitted+1] = (v == "*" and ".*") or v
end
end
-function executer.finalize() -- todo: os.exec, todo: report ipv print
- local execute = os.execute
- function executer.execute(...)
- local t, name, arguments = {...}, "", ""
+local function finalize() -- todo: os.exec, todo: report ipv print
+ execute = function(...)
+ -- todo: make more clever first split
+ local t, name, arguments = { ... }, "", ""
+ local one = t[1]
if #t == 1 then
- if type(t[1]) == 'table' then
- name, arguments = t[1], concat(t," ",2,#t)
+ if type(one) == 'table' then
+ name, arguments = one, concat(t," ",2,#t)
else
- name, arguments = match(t[1],"^(.-)%s+(.+)$")
+ name, arguments = match(one,"^(.-)%s+(.+)$")
if not (name and arguments) then
- name, arguments = t[1], ""
+ name, arguments = one, ""
end
end
else
- name, arguments = t[1], concat(t," ",2,#t)
+ name, arguments = one, concat(t," ",2,#t)
end
- local permitted = executer.permitted
for k=1,#permitted do
local v = permitted[k]
if find(name,v) then
- execute(name .. " " .. arguments)
+ osexecute(name .. " " .. arguments)
-- print("executed: " .. name .. " " .. arguments)
else
- print("not permitted: " .. name .. " " .. arguments)
+ report_executers("not permitted: %s %s",name,arguments)
end
end
end
- function executer.finalize()
- print("executer is already finalized")
+ finalize = function()
+ report_executers("already finalized")
end
- function executer.register(name)
- print("executer is already finalized")
+ register = function()
+ report_executers("already finalized, no registration permitted")
end
- os.execute = executer.execute
+ os.execute = execute
end
---~ executer.register('.*')
---~ executer.register('*')
---~ executer.register('dir','ls')
---~ executer.register('dir')
+executers.finalize = function(...) finalize(...) end
+executers.register = function(...) register(...) end
+executers.execute = function(...) execute (...) end
+
+local execution_mode directives.register("system.executionmode", function(v) execution_mode = v end)
+local execution_list directives.register("system.executionlist", function(v) execution_list = v end)
---~ executer.finalize()
---~ executer.execute('dir',"*.tex")
---~ executer.execute("dir *.tex")
---~ executer.execute("ls *.tex")
+function executers.check()
+ if execution_mode == "none" then
+ finalize()
+ elseif execution_mode == "list" and execution_list ~= "" then
+ for s in gmatch("[^%s,]",execution_list) do
+ register(s)
+ end
+ finalize()
+ else
+ -- all
+ end
+end
+
+--~ resolvers.executers.register('.*')
+--~ resolvers.executers.register('*')
+--~ resolvers.executers.register('dir','ls')
+--~ resolvers.executers.register('dir')
+
+--~ resolvers.executers.finalize()
+--~ resolvers.executers.execute('dir',"*.tex")
+--~ resolvers.executers.execute("dir *.tex")
+--~ resolvers.executers.execute("ls *.tex")
--~ os.execute('ls')
+
+--~ resolvers.executers.check()