diff options
author | Philipp Gesang <phg42.2a@gmail.com> | 2013-04-13 19:22:17 +0200 |
---|---|---|
committer | Philipp Gesang <phg42.2a@gmail.com> | 2013-04-13 19:22:17 +0200 |
commit | 419e509d1b2760c0f84bd825ed6a0cb107cee45f (patch) | |
tree | b1ce4bb1f76e7582e21d07006d742f7c67c5feca | |
parent | 7cead7f43cd14b36b30c42544ef1a458df8fdf5a (diff) | |
download | lualibs-419e509d1b2760c0f84bd825ed6a0cb107cee45f.tar.gz |
fix fake Context layer
-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 |