diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/context/lua/luatools.lua | 87 | ||||
-rw-r--r-- | scripts/context/lua/mtx-watch.lua | 6 | ||||
-rw-r--r-- | scripts/context/lua/mtxrun.lua | 87 | ||||
-rw-r--r-- | scripts/context/stubs/mswin/luatools.lua | 87 | ||||
-rw-r--r-- | scripts/context/stubs/mswin/mtxrun.lua | 87 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/luatools | 87 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/mtxrun | 87 |
7 files changed, 447 insertions, 81 deletions
diff --git a/scripts/context/lua/luatools.lua b/scripts/context/lua/luatools.lua index 9a04cc0b2..36c6c6e38 100644 --- a/scripts/context/lua/luatools.lua +++ b/scripts/context/lua/luatools.lua @@ -5253,18 +5253,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 @@ -5281,21 +5333,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 .") + else + 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" } diff --git a/scripts/context/lua/mtx-watch.lua b/scripts/context/lua/mtx-watch.lua index 33dc08928..8864b44ba 100644 --- a/scripts/context/lua/mtx-watch.lua +++ b/scripts/context/lua/mtx-watch.lua @@ -145,10 +145,10 @@ function scripts.watch.watch() local path, base = replacements.outputpath, file.basename(replacements.filename) joblog.runtime = clock() - joblog.runtime if base ~= "" then - joblog.result = file.replacesuffix(file.join(path,base),"pdf") - joblog.size = lfs.attributes(joblog.result,"size") + joblog.result = file.replacesuffix(file.join(path,base),"pdf") + joblog.size = lfs.attributes(joblog.result,"size") end - joblog.status = "finished" + joblog.status = "finished" else joblog.status = "invalid command" end 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" } diff --git a/scripts/context/stubs/mswin/luatools.lua b/scripts/context/stubs/mswin/luatools.lua index 9a04cc0b2..36c6c6e38 100644 --- a/scripts/context/stubs/mswin/luatools.lua +++ b/scripts/context/stubs/mswin/luatools.lua @@ -5253,18 +5253,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 @@ -5281,21 +5333,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 .") + else + 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" } diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index b1327ae52..d940eae46 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/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" } diff --git a/scripts/context/stubs/unix/luatools b/scripts/context/stubs/unix/luatools index 9a04cc0b2..36c6c6e38 100755 --- a/scripts/context/stubs/unix/luatools +++ b/scripts/context/stubs/unix/luatools @@ -5253,18 +5253,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 @@ -5281,21 +5333,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 .") + else + 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" } diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index b1327ae52..d940eae46 100755 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -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" } |