diff options
Diffstat (limited to 'scripts/context/lua/mtxrun.lua')
-rw-r--r-- | scripts/context/lua/mtxrun.lua | 87 |
1 files changed, 74 insertions, 13 deletions
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index b1327ae52..d940eae46 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -8343,18 +8343,70 @@ end local args = environment and environment.original_arguments or arg -- this needs a cleanup -resolvers.ownbin = resolvers.ownbin or args[-2] or arg[-2] or args[-1] or arg[-1] or arg [0] or "luatex" -resolvers.ownbin = string.gsub(resolvers.ownbin,"\\","/") -resolvers.ownpath = resolvers.ownpath or file.dirname(resolvers.ownbin) +--~ resolvers.ownbin = resolvers.ownbin or args[-2] or arg[-2] or args[-1] or arg[-1] or arg [0] or "luatex" +--~ resolvers.ownbin = string.gsub(resolvers.ownbin,"\\","/") +--~ resolvers.ownpath = resolvers.ownpath or file.dirname(resolvers.ownbin) -resolvers.autoselfdir = true -- false may be handy for debugging +--~ resolvers.autoselfdir = true -- false may be handy for debugging + +--~ function resolvers.getownpath() +--~ if not resolvers.ownpath then +--~ if resolvers.autoselfdir and os.selfdir and os.selfdir ~= "" then +--~ resolvers.ownpath = os.selfdir +--~ else +--~ local binary = resolvers.ownbin +--~ if os.binsuffix ~= "" then +--~ binary = file.replacesuffix(binary,os.binsuffix) +--~ end +--~ for p in gmatch(os.getenv("PATH"),"[^"..io.pathseparator.."]+") do +--~ local b = file.join(p,binary) +--~ if lfs.isfile(b) then +--~ -- we assume that after changing to the path the currentdir function +--~ -- resolves to the real location and use this side effect here; this +--~ -- trick is needed because on the mac installations use symlinks in the +--~ -- path instead of real locations +--~ local olddir = lfs.currentdir() +--~ if lfs.chdir(p) then +--~ local pp = lfs.currentdir() +--~ if trace_locating and p ~= pp then +--~ logs.report("fileio","following symlink '%s' to '%s'",p,pp) +--~ end +--~ resolvers.ownpath = pp +--~ lfs.chdir(olddir) +--~ else +--~ if trace_locating then +--~ logs.report("fileio","unable to check path '%s'",p) +--~ end +--~ resolvers.ownpath = p +--~ end +--~ break +--~ end +--~ end +--~ end +--~ if not resolvers.ownpath then resolvers.ownpath = '.' end +--~ end +--~ return resolvers.ownpath +--~ end + +local args = environment and environment.original_arguments or arg -- this needs a cleanup + +resolvers.ownbin = resolvers.ownbin or args[-2] or arg[-2] or args[-1] or arg[-1] or arg[0] or "luatex" +resolvers.ownbin = string.gsub(resolvers.ownbin,"\\","/") function resolvers.getownpath() - if not resolvers.ownpath then - if resolvers.autoselfdir and os.selfdir and os.selfdir ~= "" then - resolvers.ownpath = os.selfdir - else - local binary = resolvers.ownbin + local ownpath = resolvers.ownpath or os.selfdir + if not ownpath or ownpath == "" then + ownpath = args[-1] or arg[-1] + ownpath = ownpath and file.dirname(string.gsub(ownpath,"\\","/")) + if not ownpath or ownpath == "" then + ownpath = args[-0] or arg[-0] + ownpath = ownpath and file.dirname(string.gsub(ownpath,"\\","/")) + end + local binary = resolvers.ownbin + if not ownpath or ownpath == "" then + ownpath = ownpath and file.dirname(binary) + end + if not ownpath or ownpath == "" then if os.binsuffix ~= "" then binary = file.replacesuffix(binary,os.binsuffix) end @@ -8371,21 +8423,30 @@ function resolvers.getownpath() if trace_locating and p ~= pp then logs.report("fileio","following symlink '%s' to '%s'",p,pp) end - resolvers.ownpath = pp + ownpath = pp lfs.chdir(olddir) else if trace_locating then logs.report("fileio","unable to check path '%s'",p) end - resolvers.ownpath = p + ownpath = p end break end end end - if not resolvers.ownpath then resolvers.ownpath = '.' end + if not ownpath or ownpath == "" then + ownpath = "." + logs.report("fileio","forcing fallback ownpath .") + elseif trace_locating then + logs.report("fileio","using ownpath '%s'",ownpath) + end + end + resolvers.ownpath = ownpath + function resolvers.getownpath() + return resolvers.ownpath end - return resolvers.ownpath + return ownpath end local own_places = { "SELFAUTOLOC", "SELFAUTODIR", "SELFAUTOPARENT", "TEXMFCNF" } |