forked from sile-typesetter/sile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sile.in
executable file
·74 lines (59 loc) · 1.93 KB
/
sile.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!@LUA@
-- globals used only in core/packagemanager, soon to be deprecated
SYSTEM_SILE_PATH = "@SILE_PATH@"
SHARED_LIB_EXT = "@SHARED_LIB_EXT@"
-- At this point at run time we may or may not have anything useful in package.path,
-- so require() isn't something we can rely on.
local status
for path in string.gmatch("@SILE_PATH@", "[^;]+") do
status = pcall(dofile, path .. "/core/pathsetup.lua")
if status then break end
end
if not status then
dofile("./core/pathsetup.lua")
end
-- On FreeBSD, Lua's debug module doesn't give us info above the top of the stack.
-- Since our detection is currently burried in a module it doesn't tell us the executable.
if _G.executablePath == "=[C]" then
_G.executablePath = debug.getinfo(1, "S").source
end
-- This global is set here and *also* in the core library, since this
-- effectively passes the same table they are interchangeable (for now).
SILE = require("core.sile")
SILE.cli:parseArguments()
if not os.getenv 'LUA_REPL_RLWRAP' and not SILE.quiet then
io.stderr:write(SILE.full_version .. '\n')
end
SILE.init()
if SILE.input.filenames and #SILE.input.filenames >= 1 then
-- Deprecated, notice given in core.cli when argument used
for _, path in ipairs(SILE.input.includes) do
if not SILE.quiet then
io.stderr:write("Loading "..path.."\n")
end
local c = SILE.resolveFile(path, "classes")
if c then
SILE.processFile(c)
else
SILE.require(path, "classes")
end
end
for _, spec in ipairs(SILE.input.uses) do
SILE.use(spec.module, spec.options)
end
local main, err = xpcall(function()
pl.tablex.imap(SILE.processFile, SILE.input.filenames)
end, SILE.errorHandler)
if not main then
if type(err) == "string" and err:match(": interrupted!") then
SILE.outputter:finish()
else
io.stderr:write("\nerror summary:\n\t" .. tostring(err) .. "\n")
end
os.exit(1)
end
SILE.finish()
else
SILE.repl:enter()
end
-- vim: ft=lua