diff options
-rw-r--r-- | lualibs-extended.lua | 21 | ||||
-rw-r--r-- | lualibs.lua | 2 |
2 files changed, 19 insertions, 4 deletions
diff --git a/lualibs-extended.lua b/lualibs-extended.lua index c5728ea..a6550db 100644 --- a/lualibs-extended.lua +++ b/lualibs-extended.lua @@ -73,7 +73,17 @@ local fake_trackers = function (name) } end -local backup_store +--[[doc-- +Among the libraries loaded is \verb|util-env.lua|, which adds +\CONTEXT’s own, superior command line argument handler. +Packages that rely on their own handling of arguments might not be +aware of this, or the library might have been loaded by another package +altogether. +For these cases we provide a copy of the original \verb|arg| list and +restore it after we are done loading. +--doc]]-- + +local backup_store --- will be populated after util-sto local fake_context = function ( ) if not backup_store then backup_store = utilities.storage.allocate() @@ -82,16 +92,21 @@ local fake_context = function ( ) if _G.trackers then backup_store.trackers = _G.trackers end _G.logs = fake_logs"logs" _G.trackers = fake_trackers"trackers" + + backup_store.argv = table.fastcopy(_G.arg) end + --[[doc-- Restore a backed up logger if appropriate. --doc]]-- local unfake_context = function ( ) if backup_store then local bl, bt = backup_store.logs, backup_store.trackers - if bl then _G.logs = bl end - if bt then _G.trackers = bt end + local argv = backup_store.argv + if bl then _G.logs = bl end + if bt then _G.trackers = bt end + if argv then _G.arg = argv end end end diff --git a/lualibs.lua b/lualibs.lua index ec02a5a..cd0034e 100644 --- a/lualibs.lua +++ b/lualibs.lua @@ -87,7 +87,7 @@ the split into luat-bas.mkiv and luat-lib.mkiv. loadmerged"basic.lua" --inspect(table.keys(table)) --inspect(table.keys(string)) -if load_extended then +if load_extended == true then loadmerged"extended.lua" end |