summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/l-os.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/l-os.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/l-os.lua132
1 files changed, 15 insertions, 117 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/l-os.lua b/Master/texmf-dist/tex/context/base/mkiv/l-os.lua
index cf469f79d32..9b54c9840c4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/l-os.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/l-os.lua
@@ -32,78 +32,11 @@ local concat = table.concat
local random, ceil, randomseed = math.random, math.ceil, math.randomseed
local rawget, rawset, type, getmetatable, setmetatable, tonumber, tostring = rawget, rawset, type, getmetatable, setmetatable, tonumber, tostring
--- This check needs to happen real early on. Todo: we can pick it up from the commandline
--- if we pass --binpath= (which is useful anyway)
-
-do
- local selfdir = os.selfdir
- if selfdir == "" then
- selfdir = nil
- end
- if not selfdir then
- -- We need a fallback plan so let's see what we get.
- if arg then
- -- passed by mtx-context ... saves network access
- for i=1,#arg do
- local a = arg[i]
- if find(a,"^%-%-[c:]*texmfbinpath=") then
- selfdir = gsub(a,"^.-=","")
- break
- end
- end
- end
- if not selfdir then
- selfdir = os.selfbin or "luatex"
- if find(selfdir,"[/\\]") then
- selfdir = gsub(selfdir,"[/\\][^/\\]*$","")
- elseif os.getenv then
- local path = os.getenv("PATH")
- local name = gsub(selfdir,"^.*[/\\][^/\\]","")
- local patt = "[^:]+"
- if os.type == "windows" then
- patt = "[^;]+"
- name = name .. ".exe"
- end
- local isfile
- if lfs then
- -- we're okay as lfs is assumed present
- local attributes = lfs.attributes
- isfile = function(name)
- local a = attributes(name,"mode")
- return a == "file" or a == "link" or nil
- end
- else
- -- we're not okay and much will not work as we miss lfs
- local open = io.open
- isfile = function(name)
- local f = open(name)
- if f then
- f:close()
- return true
- end
- end
- end
- for p in gmatch(path,patt) do
- -- possible speedup: there must be tex in 'p'
- if isfile(p .. "/" .. name) then
- selfdir = p
- break
- end
- end
- end
- end
- -- let's hope we're okay now
- os.selfdir = selfdir or "."
- end
-end
--- print(os.selfdir) os.exit()
-
--- The following code permits traversing the environment table, at least in luatex. Internally all
--- environment names are uppercase.
+-- The following code permits traversing the environment table, at least
+-- in luatex. Internally all environment names are uppercase.
-- The randomseed in Lua is not that random, although this depends on the operating system as well
--- as the binary (Luatex is normally okay). But to be sure we set the seed anyway. It will be better
--- in Lua 5.4 (according to the announcements.)
+-- as the binary (Luatex is normally okay). But to be sure we set the seed anyway.
math.initialseed = tonumber(string.sub(string.reverse(tostring(ceil(socket and socket.gettime()*10000 or time()))),1,6))
@@ -223,7 +156,7 @@ end
local launchers = {
windows = "start %s",
macosx = "open %s",
- unix = "xdg-open %s &> /dev/null &",
+ unix = "$BROWSER %s &> /dev/null &",
}
function os.launch(str)
@@ -290,13 +223,6 @@ local name, platform = os.name or "linux", os.getenv("MTX_PLATFORM") or ""
-- os.bits = 32 | 64
--- os.uname()
--- sysname
--- machine
--- release
--- version
--- nodename
-
if platform ~= "" then
os.platform = platform
@@ -308,12 +234,10 @@ elseif os.type == "windows" then
-- PROCESSOR_ARCHITECTURE : binary platform
-- PROCESSOR_ARCHITEW6432 : OS platform
- -- mswin-64 is now win64
-
function resolvers.platform(t,k)
- local architecture = os.getenv("PROCESSOR_ARCHITECTURE") or ""
- local platform = ""
+ local platform, architecture = "", os.getenv("PROCESSOR_ARCHITECTURE") or ""
if find(architecture,"AMD64",1,true) then
+ -- platform = "mswin-64"
platform = "win64"
else
platform = "mswin"
@@ -327,17 +251,13 @@ elseif name == "linux" then
function resolvers.platform(t,k)
-- we sometimes have HOSTTYPE set so let's check that first
- local architecture = os.getenv("HOSTTYPE") or resultof("uname -m") or ""
- local platform = os.getenv("MTX_PLATFORM") or ""
- local musl = find(os.selfdir or "","linuxmusl")
- if platform ~= "" then
- -- we're done
- elseif find(architecture,"x86_64",1,true) then
- platform = musl and "linuxmusl" or "linux-64"
+ local platform, architecture = "", os.getenv("HOSTTYPE") or resultof("uname -m") or ""
+ if find(architecture,"x86_64",1,true) then
+ platform = "linux-64"
elseif find(architecture,"ppc",1,true) then
platform = "linux-ppc"
else
- platform = musl and "linuxmusl" or "linux"
+ platform = "linux"
end
os.setenv("MTX_PLATFORM",platform)
os.platform = platform
@@ -357,13 +277,11 @@ elseif name == "macosx" then
]]--
function resolvers.platform(t,k)
- -- local platform = ""
- -- local architecture = os.getenv("HOSTTYPE") or ""
+ -- local platform, architecture = "", os.getenv("HOSTTYPE") or ""
-- if architecture == "" then
-- architecture = resultof("echo $HOSTTYPE") or ""
-- end
- local architecture = resultof("echo $HOSTTYPE") or ""
- local platform = ""
+ local platform, architecture = "", resultof("echo $HOSTTYPE") or ""
if architecture == "" then
-- print("\nI have no clue what kind of OSX you're running so let's assume an 32 bit intel.\n")
platform = "osx-intel"
@@ -382,8 +300,7 @@ elseif name == "macosx" then
elseif name == "sunos" then
function resolvers.platform(t,k)
- local architecture = resultof("uname -m") or ""
- local platform = ""
+ local platform, architecture = "", resultof("uname -m") or ""
if find(architecture,"sparc",1,true) then
platform = "solaris-sparc"
else -- if architecture == 'i86pc'
@@ -397,8 +314,7 @@ elseif name == "sunos" then
elseif name == "freebsd" then
function resolvers.platform(t,k)
- local architecture = resultof("uname -m") or ""
- local platform = ""
+ local platform, architecture = "", resultof("uname -m") or ""
if find(architecture,"amd64",1,true) then
platform = "freebsd-amd64"
else
@@ -413,8 +329,7 @@ elseif name == "kfreebsd" then
function resolvers.platform(t,k)
-- we sometimes have HOSTTYPE set so let's check that first
- local architecture = os.getenv("HOSTTYPE") or resultof("uname -m") or ""
- local platform = ""
+ local platform, architecture = "", os.getenv("HOSTTYPE") or resultof("uname -m") or ""
if find(architecture,"x86_64",1,true) then
platform = "kfreebsd-amd64"
else
@@ -649,20 +564,3 @@ function os.validdate(year,month,day)
end
return year, month, day
end
-
-local osexit = os.exit
-local exitcode = nil
-
-function os.setexitcode(code)
- exitcode = code
-end
-
-function os.exit(c)
- if exitcode ~= nil then
- return osexit(exitcode)
- end
- if c ~= nil then
- return osexit(c)
- end
- return osexit()
-end