summaryrefslogtreecommitdiff
path: root/scripts/context/lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2009-11-27 21:24:00 +0100
committerHans Hagen <pragma@wxs.nl>2009-11-27 21:24:00 +0100
commite55a0f36ef512134e32c0c11b1ede843dd4eb145 (patch)
tree74bdeede47e9cb6c1a109399d5b033bf450f6aed /scripts/context/lua
parent527274eadad499558bb40b794882661970c5cc67 (diff)
downloadcontext-e55a0f36ef512134e32c0c11b1ede843dd4eb145.tar.gz
beta 2009.11.27 21:24
Diffstat (limited to 'scripts/context/lua')
-rw-r--r--scripts/context/lua/luatools.lua52
-rw-r--r--scripts/context/lua/luatools.rme2
-rw-r--r--scripts/context/lua/mtx-babel.lua2
-rw-r--r--scripts/context/lua/mtx-cache.lua2
-rw-r--r--scripts/context/lua/mtx-chars.lua24
-rw-r--r--scripts/context/lua/mtx-check.lua2
-rw-r--r--scripts/context/lua/mtx-context.lua2
-rw-r--r--scripts/context/lua/mtx-convert.lua2
-rw-r--r--scripts/context/lua/mtx-fonts.lua2
-rw-r--r--scripts/context/lua/mtx-interface.lua2
-rw-r--r--scripts/context/lua/mtx-metatex.lua2
-rw-r--r--scripts/context/lua/mtx-modules.lua2
-rw-r--r--scripts/context/lua/mtx-package.lua2
-rw-r--r--scripts/context/lua/mtx-patterns.lua2
-rw-r--r--scripts/context/lua/mtx-profile.lua2
-rw-r--r--scripts/context/lua/mtx-server.lua2
-rw-r--r--scripts/context/lua/mtx-texworks.lua2
-rw-r--r--scripts/context/lua/mtx-timing.lua2
-rw-r--r--scripts/context/lua/mtx-tools.lua2
-rw-r--r--scripts/context/lua/mtx-update.lua2
-rw-r--r--scripts/context/lua/mtx-watch.lua2
-rw-r--r--scripts/context/lua/mtxrun.lua92
-rw-r--r--scripts/context/lua/mtxrun.rme21
23 files changed, 150 insertions, 77 deletions
diff --git a/scripts/context/lua/luatools.lua b/scripts/context/lua/luatools.lua
index 692213b09..6feb7a9c5 100644
--- a/scripts/context/lua/luatools.lua
+++ b/scripts/context/lua/luatools.lua
@@ -1780,6 +1780,7 @@ function os.currentplatform(name,default)
platform = "linux"
end
elseif name == "macosx" then
+ local architecture = os.resultof("echo $HOSTTYPE")
if find(architecture,"i386") then
platform = "osx-intel"
elseif find(architecture,"x86_64") then
@@ -1881,8 +1882,8 @@ function file.nameonly(name)
return (gsub(match(name,"^.+[/\\](.-)$") or name,"%..*$",""))
end
-function file.extname(name)
- return match(name,"^.+%.([^/\\]-)$") or ""
+function file.extname(name,default)
+ return match(name,"^.+%.([^/\\]-)$") or default or ""
end
file.suffix = file.extname
@@ -3757,7 +3758,7 @@ end
if arg then
- -- new, reconstruct quoted snippets (maybe better just remnove the " then and add them later)
+ -- new, reconstruct quoted snippets (maybe better just remove the " then and add them later)
local newarg, instring = { }, false
for index, argument in ipairs(arg) do
@@ -4077,6 +4078,9 @@ if not modules then modules = { } end modules ['luat-log'] = {
-- this is old code that needs an overhaul
+--~ io.stdout:setvbuf("no")
+--~ io.stderr:setvbuf("no")
+
local write_nl, write, format = texio.write_nl or print, texio.write or io.write, string.format
local texcount = tex and tex.count
@@ -4158,27 +4162,49 @@ function logs.tex.line(fmt,...) -- new
end
end
+--~ function logs.tex.start_page_number()
+--~ local real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno
+--~ if real > 0 then
+--~ if user > 0 then
+--~ if sub > 0 then
+--~ write(format("[%s.%s.%s",real,user,sub))
+--~ else
+--~ write(format("[%s.%s",real,user))
+--~ end
+--~ else
+--~ write(format("[%s",real))
+--~ end
+--~ else
+--~ write("[-")
+--~ end
+--~ end
+
+--~ function logs.tex.stop_page_number()
+--~ write("]")
+--~ end
+
+local real, user, sub
+
function logs.tex.start_page_number()
- local real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno
+ real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno
+end
+
+function logs.tex.stop_page_number()
if real > 0 then
if user > 0 then
if sub > 0 then
- write(format("[%s.%s.%s",real,user,sub))
+ logs.report("pages", "flushing page, realpage %s, userpage %s, subpage %s",real,user,sub)
else
- write(format("[%s.%s",real,user))
+ logs.report("pages", "flushing page, realpage %s, userpage %s",real,user)
end
else
- write(format("[%s",real))
+ logs.report("pages", "flushing page, realpage %s",real)
end
else
- write("[-")
+ logs.report("pages", "flushing page")
end
end
-function logs.tex.stop_page_number()
- write("]")
-end
-
logs.tex.report_job_stat = statistics.show_job_stat
-- xml logging
@@ -4621,7 +4647,7 @@ function resolvers.settrace(n) -- no longer number but: 'locating' or 'detail'
end
end
-resolvers.settrace(os.getenv("MTX.resolvers.TRACE") or os.getenv("MTX_INPUT_TRACE"))
+resolvers.settrace(os.getenv("MTX_INPUT_TRACE"))
function resolvers.osenv(key)
local ie = instance.environment
diff --git a/scripts/context/lua/luatools.rme b/scripts/context/lua/luatools.rme
index b320e1184..901e9a9a3 100644
--- a/scripts/context/lua/luatools.rme
+++ b/scripts/context/lua/luatools.rme
@@ -1,3 +1,3 @@
On MSWindows the luatools.lua script is called
-with luatools.cmd. On Unix you can either rename
+with luatools.exe. On Unix you can either rename
luatools.lua to luatools, or use a symlink.
diff --git a/scripts/context/lua/mtx-babel.lua b/scripts/context/lua/mtx-babel.lua
index e241e9334..01e2ba4b2 100644
--- a/scripts/context/lua/mtx-babel.lua
+++ b/scripts/context/lua/mtx-babel.lua
@@ -415,7 +415,7 @@ do
end
-logs.extendbanner("Babel Conversion Tools 1.2",true)
+logs.extendbanner("Babel Input To UTF Conversion 1.20",true)
messages.help = [[
--language=string conversion language (e.g. greek)
diff --git a/scripts/context/lua/mtx-cache.lua b/scripts/context/lua/mtx-cache.lua
index a1fbed825..9f54d9754 100644
--- a/scripts/context/lua/mtx-cache.lua
+++ b/scripts/context/lua/mtx-cache.lua
@@ -76,7 +76,7 @@ function scripts.cache.list(all)
end)
end
-logs.extendbanner("Cache Tools 0.10")
+logs.extendbanner("ConTeXt & MetaTeX Cache Management 0.10")
messages.help = [[
--purge remove not used files
diff --git a/scripts/context/lua/mtx-chars.lua b/scripts/context/lua/mtx-chars.lua
index d4330ca30..0b93587a3 100644
--- a/scripts/context/lua/mtx-chars.lua
+++ b/scripts/context/lua/mtx-chars.lua
@@ -11,17 +11,17 @@ local format, concat, utfchar, upper = string.format, table.concat, unicode.utf8
scripts = scripts or { }
scripts.chars = scripts.chars or { }
-local banner = [[
--- filename : char-mth.lua
--- comment : companion to char-mth.tex (in ConTeXt)
--- author : Hans Hagen, PRAGMA-ADE, Hasselt NL
--- license : see context related readme files
--- comment : generated from data file downloaded from STIX website
-
-if not versions then versions = { } end versions['char-mth'] = 1.001
-if not characters then characters = { } end
-]]
-
+--~ local banner = [[
+--~ -- filename : char-mth.lua
+--~ -- comment : companion to char-mth.tex (in ConTeXt)
+--~ -- author : Hans Hagen, PRAGMA-ADE, Hasselt NL
+--~ -- license : see context related readme files
+--~ -- comment : generated from data file downloaded from STIX website
+--~
+--~ if not versions then versions = { } end versions['char-mth'] = 1.001
+--~ if not characters then characters = { } end
+--~ ]]
+--~
--~ function scripts.chars.stixtomkiv(inname,outname)
--~ if inname == "" then
--~ logs.report("aquiring math data","invalid datafilename")
@@ -301,7 +301,7 @@ function scripts.chars.makeencoutf()
end
end
-logs.extendbanner("Character Tools 0.10")
+logs.extendbanner("MkII Character Table Generators 0.10")
messages.help = [[
--stix convert stix table to math table
diff --git a/scripts/context/lua/mtx-check.lua b/scripts/context/lua/mtx-check.lua
index 6be7f2765..436a205e0 100644
--- a/scripts/context/lua/mtx-check.lua
+++ b/scripts/context/lua/mtx-check.lua
@@ -123,7 +123,7 @@ function scripts.checker.check(filename)
end
end
-logs.extendbanner("Syntax Checking 0.10",true)
+logs.extendbanner("Basic ConTeXt Syntax Checking 0.10",true)
messages.help = [[
--convert check tex file for errors
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua
index b146b3c09..2ed661774 100644
--- a/scripts/context/lua/mtx-context.lua
+++ b/scripts/context/lua/mtx-context.lua
@@ -1381,7 +1381,7 @@ function scripts.context.update()
end
end
-logs.extendbanner("ConTeXt Tools 0.51",true)
+logs.extendbanner("ConTeXt Process Management 0.51",true)
messages.help = [[
--run process (one or more) files (default action)
diff --git a/scripts/context/lua/mtx-convert.lua b/scripts/context/lua/mtx-convert.lua
index 5e9a71573..cb514720e 100644
--- a/scripts/context/lua/mtx-convert.lua
+++ b/scripts/context/lua/mtx-convert.lua
@@ -118,7 +118,7 @@ function scripts.convert.convertgiven()
end
-logs.extendbanner("Graphic Conversion Tools 0.10",true)
+logs.extendbanner("ConTeXT Graphic Conversion Helpers 0.10",true)
messages.help = [[
--convertall convert all graphics on path
diff --git a/scripts/context/lua/mtx-fonts.lua b/scripts/context/lua/mtx-fonts.lua
index 4d3e52382..bc93eaaa9 100644
--- a/scripts/context/lua/mtx-fonts.lua
+++ b/scripts/context/lua/mtx-fonts.lua
@@ -281,7 +281,7 @@ function scripts.fonts.save()
end
end
-logs.extendbanner("Font Tools 0.21",true)
+logs.extendbanner("ConTeXt Font Database Management 0.21",true)
messages.help = [[
--save save open type font in raw table
diff --git a/scripts/context/lua/mtx-interface.lua b/scripts/context/lua/mtx-interface.lua
index 264a2dbe4..4aaa3b5a0 100644
--- a/scripts/context/lua/mtx-interface.lua
+++ b/scripts/context/lua/mtx-interface.lua
@@ -234,7 +234,7 @@ function scripts.interface.messages()
end
end
-logs.extendbanner("Interface Tools 0.11",true)
+logs.extendbanner("ConTeXt Interface Related Goodies 0.11",true)
messages.help = [[
--scite generate scite interface
diff --git a/scripts/context/lua/mtx-metatex.lua b/scripts/context/lua/mtx-metatex.lua
index f8c871a7b..4453e2ccb 100644
--- a/scripts/context/lua/mtx-metatex.lua
+++ b/scripts/context/lua/mtx-metatex.lua
@@ -49,7 +49,7 @@ function scripts.metatex.timed(action)
statistics.timed(action)
end
-logs.extendbanner("MetaTeX Tools 0.10",true)
+logs.extendbanner("MetaTeX Process Management 0.10",true)
messages.help = [[
--run process (one or more) files (default action)
diff --git a/scripts/context/lua/mtx-modules.lua b/scripts/context/lua/mtx-modules.lua
index 1a6593004..9ade1fc23 100644
--- a/scripts/context/lua/mtx-modules.lua
+++ b/scripts/context/lua/mtx-modules.lua
@@ -147,7 +147,7 @@ end
-- context --ctx=m-modules.ctx xxx.mkiv
-logs.extendbanner("Module Documentation Tools 1.0",true)
+logs.extendbanner("ConTeXt Module Documentation Generators 1.00",true)
messages.help = [[
--convert convert source files (tex, mkii, mkiv, mp) to 'ted' files
diff --git a/scripts/context/lua/mtx-package.lua b/scripts/context/lua/mtx-package.lua
index 06c89907a..b36fc0ed8 100644
--- a/scripts/context/lua/mtx-package.lua
+++ b/scripts/context/lua/mtx-package.lua
@@ -55,7 +55,7 @@ function scripts.package.merge_luatex_files(name,strip)
end
end
-logs.extendbanner("Package Tools 0.1",true)
+logs.extendbanner("Distribution Related Goodies 0.10",true)
messages.help = [[
--merge merge 'loadmodule' into merge file
diff --git a/scripts/context/lua/mtx-patterns.lua b/scripts/context/lua/mtx-patterns.lua
index 7f130465b..758ea55c9 100644
--- a/scripts/context/lua/mtx-patterns.lua
+++ b/scripts/context/lua/mtx-patterns.lua
@@ -337,7 +337,7 @@ function scripts.patterns.convert()
end
end
-logs.extendbanner("Pattern Tools 0.20",true)
+logs.extendbanner("ConTeXt Pattern File Management 0.20",true)
messages.help = [[
--convert generate context language files (mnemonic driven, if not given then all)
diff --git a/scripts/context/lua/mtx-profile.lua b/scripts/context/lua/mtx-profile.lua
index 1db9682ac..9e2aed288 100644
--- a/scripts/context/lua/mtx-profile.lua
+++ b/scripts/context/lua/mtx-profile.lua
@@ -148,7 +148,7 @@ end
--~ scripts.profiler.analyse("t:/manuals/mk/mk-fonts-profile.lua")
--~ scripts.profiler.analyse("t:/manuals/mk/mk-introduction-profile.lua")
-logs.extendbanner("LuaTeX Profiler 1.00",true)
+logs.extendbanner("ConTeXt MkIV LuaTeX Profiler 1.00",true)
messages.help = [[
--analyse analyse lua calls
diff --git a/scripts/context/lua/mtx-server.lua b/scripts/context/lua/mtx-server.lua
index a1a5d51b3..871354394 100644
--- a/scripts/context/lua/mtx-server.lua
+++ b/scripts/context/lua/mtx-server.lua
@@ -326,7 +326,7 @@ function scripts.webserver.run(configuration)
end
end
-logs.extendbanner("Simple Webserver 0.10")
+logs.extendbanner("Simple Webserver For Helpers 0.10")
messages.help = [[
--start start server
diff --git a/scripts/context/lua/mtx-texworks.lua b/scripts/context/lua/mtx-texworks.lua
index 77d257480..401408b32 100644
--- a/scripts/context/lua/mtx-texworks.lua
+++ b/scripts/context/lua/mtx-texworks.lua
@@ -80,7 +80,7 @@ function scripts.texworks.start(indeed)
end
-logs.extendbanner("TeXworks startup script 1.0",true)
+logs.extendbanner("TeXworks Startup Script 1.00",true)
messages.help = [[
--start [--verbose] start texworks
diff --git a/scripts/context/lua/mtx-timing.lua b/scripts/context/lua/mtx-timing.lua
index 1dcb9aa0e..375d5d90b 100644
--- a/scripts/context/lua/mtx-timing.lua
+++ b/scripts/context/lua/mtx-timing.lua
@@ -186,7 +186,7 @@ function scripts.timings.xhtml(filename)
end
end
-logs.extendbanner("ConTeXt Timing Tools 0.1",true)
+logs.extendbanner("ConTeXt Timing Tools 0.10",true)
messages.help = [[
--xhtml make xhtml file
diff --git a/scripts/context/lua/mtx-tools.lua b/scripts/context/lua/mtx-tools.lua
index 87fd51dc6..ca2faaf29 100644
--- a/scripts/context/lua/mtx-tools.lua
+++ b/scripts/context/lua/mtx-tools.lua
@@ -44,7 +44,7 @@ function scripts.tools.disarmutfbomb()
end
end
-logs.extendbanner("All Kind Of Tools 1.0",true)
+logs.extendbanner("Some File Related Goodies 1.00",true)
messages.help = [[
--disarmutfbomb remove utf bomb if present
diff --git a/scripts/context/lua/mtx-update.lua b/scripts/context/lua/mtx-update.lua
index 3dd2f0e47..61d6b0d84 100644
--- a/scripts/context/lua/mtx-update.lua
+++ b/scripts/context/lua/mtx-update.lua
@@ -445,7 +445,7 @@ function scripts.update.make()
logs.report("make","done")
end
-logs.extendbanner("Download Tools 0.20",true)
+logs.extendbanner("ConTeXt Minimals Updater 0.21",true)
messages.help = [[
--platform=string platform (windows, linux, linux-64, osx-intel, osx-ppc, linux-ppc)
diff --git a/scripts/context/lua/mtx-watch.lua b/scripts/context/lua/mtx-watch.lua
index 2e4dcf6ef..44f61ae6b 100644
--- a/scripts/context/lua/mtx-watch.lua
+++ b/scripts/context/lua/mtx-watch.lua
@@ -239,7 +239,7 @@ function scripts.watch.show_logs(path) -- removes duplicates
end
end
-logs.extendbanner("Watchdog 1.00",true)
+logs.extendbanner("ConTeXt Request Watchdog 1.00",true)
messages.help = [[
--logpath optional path for log files
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index a187f0697..ceb9cb886 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -1789,6 +1789,7 @@ function os.currentplatform(name,default)
platform = "linux"
end
elseif name == "macosx" then
+ local architecture = os.resultof("echo $HOSTTYPE")
if find(architecture,"i386") then
platform = "osx-intel"
elseif find(architecture,"x86_64") then
@@ -4773,8 +4774,9 @@ local lp_and = P("&") / " and "
local lp_builtin = P (
P("first") / "1" +
P("last") / "#list" +
- P("position") / "l" +
+ P("position") / "l" + -- is element in finalizer
P("rootposition") / "order" +
+ P("order") / "order" +
P("index") / "(ll.ni or 1)" +
P("match") / "(ll.mi or 1)" +
P("text") / "(ll.dt[1] or '')" +
@@ -6125,11 +6127,15 @@ local function position(collected,n)
elseif n > 0 then
return collected[n]
else
- return collected[1].mi -- match
+ return collected[1].mi or 0
end
end
end
+local function match(collected)
+ return (collected and collected[1].mi) or 0 -- match
+end
+
local function index(collected)
if collected then
return collected[1].ni
@@ -6283,6 +6289,7 @@ finalizers.attribute = attribute
finalizers.att = att
finalizers.count = count
finalizers.position = position
+finalizers.match = match
finalizers.index = index
finalizers.attributes = attributes
finalizers.chainattribute = chainattribute
@@ -6334,10 +6341,14 @@ end
xml.content = text
-function xml.position(id,pattern,n)
+function xml.position(id,pattern,n) -- element
return position(xmlfilter(id,pattern),n)
end
+function xml.match(id,pattern) -- number
+ return match(xmlfilter(id,pattern))
+end
+
function xml.empty(id,pattern)
return empty(xmlfilter(id,pattern))
end
@@ -6801,7 +6812,7 @@ end -- of closure
do -- create closure to overcome 200 locals limit
-if not modules then modules = { } end modules ['luat-log'] = {
+if not modules then modules = { } end modules ['trac-log'] = {
version = 1.001,
comment = "companion to trac-log.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
@@ -7078,8 +7089,12 @@ end
logs.simpleline = logs.reportline
-function logs.help(message,option)
+function logs.reportbanner() -- for scripts too
logs.report(banner)
+end
+
+function logs.help(message,option)
+ logs.reportbanner()
logs.reportline()
logs.reportlines(message)
local moreinfo = logs.moreinfo or ""
@@ -7380,7 +7395,7 @@ function resolvers.settrace(n) -- no longer number but: 'locating' or 'detail'
end
end
-resolvers.settrace(os.getenv("MTX.resolvers.TRACE") or os.getenv("MTX_INPUT_TRACE"))
+resolvers.settrace(os.getenv("MTX_INPUT_TRACE"))
function resolvers.osenv(key)
local ie = instance.environment
@@ -10639,7 +10654,7 @@ runners = runners or { } -- global
messages = messages or { }
messages.help = [[
---script run an mtx script (--noquotes)
+--script run an mtx script (--noquotes), no script gives list
--execute run a script or program (--noquotes)
--resolve resolve prefixed arguments
--ctxlua run internally (using preloaded libs)
@@ -10685,20 +10700,17 @@ runners.suffixes = {
}
runners.registered = {
- texexec = { 'texexec.rb', true }, -- context mkii runner (only tool not to be luafied)
+ texexec = { 'texexec.rb', false }, -- context mkii runner (only tool not to be luafied)
texutil = { 'texutil.rb', true }, -- old perl based index sorter for mkii (old versions need it)
texfont = { 'texfont.pl', true }, -- perl script that makes mkii font metric files
texfind = { 'texfind.pl', false }, -- perltk based tex searching tool, mostly used at pragma
texshow = { 'texshow.pl', false }, -- perltk based context help system, will be luafied
- -- texwork = { \texwork.pl', false }, -- perltk based editing environment, only used at pragma
-
+ -- texwork = { 'texwork.pl', false }, -- perltk based editing environment, only used at pragma
makempy = { 'makempy.pl', true },
mptopdf = { 'mptopdf.pl', true },
pstopdf = { 'pstopdf.rb', true }, -- converts ps (and some more) images, does some cleaning (replaced)
-
-- examplex = { 'examplex.rb', false },
concheck = { 'concheck.rb', false },
-
runtools = { 'runtools.rb', true },
textools = { 'textools.rb', true },
tmftools = { 'tmftools.rb', true },
@@ -10710,7 +10722,6 @@ runners.registered = {
xmltools = { 'xmltools.rb', true },
-- luatools = { 'luatools.lua', true },
mtxtools = { 'mtxtools.rb', true },
-
pdftrimwhite = { 'pdftrimwhite.pl', false }
}
@@ -10763,7 +10774,7 @@ function runners.prepare()
return "run"
end
-function runners.execute_script(fullname,internal)
+function runners.execute_script(fullname,internal,nosplit)
local noquote = environment.argument("noquotes")
if fullname and fullname ~= "" then
local state = runners.prepare()
@@ -10803,17 +10814,19 @@ function runners.execute_script(fullname,internal)
end
end
if result and result ~= "" then
- local before, after = environment.split_arguments(fullname) -- already done
- environment.arguments_before, environment.arguments_after = before, after
+ if not no_split then
+ local before, after = environment.split_arguments(fullname) -- already done
+ environment.arguments_before, environment.arguments_after = before, after
+ end
if internal then
- arg = { } for _,v in pairs(after) do arg[#arg+1] = v end
+ arg = { } for _,v in pairs(environment.arguments_after) do arg[#arg+1] = v end
dofile(result)
else
local binary = runners.applications[file.extname(result)]
if binary and binary ~= "" then
result = binary .. " " .. result
end
- local command = result .. " " .. environment.reconstruct_commandline(after,noquote)
+ local command = result .. " " .. environment.reconstruct_commandline(environment.arguments_after,noquote)
if logs.verbose then
logs.simpleline()
logs.simple("executing: %s",command)
@@ -10821,7 +10834,7 @@ function runners.execute_script(fullname,internal)
logs.simpleline()
io.flush()
end
- local code = os.exec(command) -- maybe spawn
+ local code = os.exec(command) -- maybe spawn
return code == 0
end
end
@@ -10855,7 +10868,7 @@ function runners.execute_program(fullname)
return false
end
--- the --usekpse flag will fallback on kpse
+-- the --usekpse flag will fallback on kpse (hm, we can better update mtx-stubs)
local windows_stub = '@echo off\013\010setlocal\013\010set ownpath=%%~dp0%%\013\010texlua "%%ownpath%%mtxrun.lua" --usekpse --execute %s %%*\013\010endlocal\013\010'
local unix_stub = '#!/bin/sh\010mtxrun --usekpse --execute %s \"$@\"\010'
@@ -11096,22 +11109,35 @@ function runners.execute_ctx_script(filename,arguments)
return true
end
else
- logs.setverbose(true)
- if filename == "" then
- logs.simple("unknown script, no name given")
+ -- logs.setverbose(true)
+ if filename == "" or filename == "help" then
local context = resolvers.find_file("mtx-context.lua")
+ logs.setverbose(true)
if context ~= "" then
local result = dir.glob((string.gsub(context,"mtx%-context","mtx-*"))) -- () needed
local valid = { }
+ table.sort(result)
for _, scriptname in ipairs(result) do
- scriptname = string.match(scriptname,".*mtx%-([^%-]-)%.lua")
- if scriptname then
- valid[#valid+1] = scriptname
+ local scriptbase = string.match(scriptname,".*mtx%-([^%-]-)%.lua")
+ if scriptbase then
+ local data = io.loaddata(scriptname)
+ local banner, version = string.match(data,"[\n\r]logs%.extendbanner%s*%(%s*[\"\']([^\n\r]+)%s*(%d+%.%d+)")
+ if banner then
+ valid[#valid+1] = { scriptbase, version, banner }
+ end
end
end
if #valid > 0 then
- logs.simple("known scripts: %s",table.concat(valid,", "))
+ logs.reportbanner()
+ logs.reportline()
+ logs.simple("no script name given, known scripts:")
+ logs.simple()
+ for k, v in ipairs(valid) do
+ logs.simple("%-12s %4s %s",v[1],v[2],v[3])
+ end
end
+ else
+ logs.simple("no script name given")
end
else
filename = file.addsuffix(filename,"lua")
@@ -11125,6 +11151,7 @@ function runners.execute_ctx_script(filename,arguments)
end
end
+
function runners.timedrun(filename) -- just for me
if filename and filename ~= "" then
runners.timed(function() os.execute(filename) end)
@@ -11152,7 +11179,9 @@ instance.lsrmode = environment.argument("lsr") or false
-- maybe the unset has to go to this level
-if environment.argument("usekpse") or environment.argument("forcekpse") then
+local is_mkii_stub = runners.registered[file.removesuffix(file.basename(filename))]
+
+if environment.argument("usekpse") or environment.argument("forcekpse") or is_mkii_stub then
os.setenv("engine","")
os.setenv("progname","")
@@ -11187,7 +11216,7 @@ if environment.argument("usekpse") or environment.argument("forcekpse") then
return (kpse_initialized():show_path(name)) or ""
end
- elseif environment.argument("usekpse") then
+ elseif environment.argument("usekpse") or is_mkii_stub then
resolvers.load()
@@ -11222,7 +11251,10 @@ if trackspec then
trackers.enable(trackspec)
end
-if environment.argument("selfmerge") then
+if is_mkii_stub then
+ -- execute mkii script
+ ok = runners.execute_script(filename,false,true)
+elseif environment.argument("selfmerge") then
-- embed used libraries
utils.merger.selfmerge(own.name,own.libs,own.list)
elseif environment.argument("selfclean") then
diff --git a/scripts/context/lua/mtxrun.rme b/scripts/context/lua/mtxrun.rme
index 9cb56486a..9850e389d 100644
--- a/scripts/context/lua/mtxrun.rme
+++ b/scripts/context/lua/mtxrun.rme
@@ -1,3 +1,18 @@
-On MSWindows the mtxrun.lua script is called
-with mtxrun.cmd. On Unix you can either rename
-mtxrun.lua to mtxrun, or use a symlink.
+On MSWindows the mtxrun.lua script is called with
+mtxrun.exe. On Unix you can either rename mtxrun.lua
+to mtxrun, or use a symlink.
+
+You can create additional stubs, like
+
+copy mtxrun.exe luatools.exe
+copy mtxrun.exe texexec.exe
+copy mtxrun.exe context.exe
+copy mtxrun.exe mtx-server.exe
+
+The mtxrun.exe program is rather dump and only
+intercepts mtxrun, luatools and texmfstart (for
+old times sake) and passes the buck to mtxrun.lua
+which happens to know enough of mkii to deal
+with kpse based lookups and therefore acts like
+texmfstart but when used with mkiv it behaves
+more clever and looks for more.