-
-
Notifications
You must be signed in to change notification settings - Fork 99
/
sile.in
executable file
·60 lines (49 loc) · 1.65 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
#!@LUA@
-- 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 buried 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.full_version = SILE.full_version .. " [Lua]"
local cli = require("core.cli")
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
for _, spec in ipairs(SILE.input.uses) do
SILE.use(spec.module, spec.options)
end
local process_status, error_msg = xpcall(function ()
pl.tablex.imap(SILE.processFile, SILE.input.filenames)
end, SILE.errorHandler)
if not process_status then
if type(error_msg) == "string" and error_msg:match(": interrupted!") then
SILE.outputter:finish()
else
io.stderr:write("\nerror summary:\n\t" .. tostring(error_msg) .. "\n")
end
os.exit(1)
end
SILE.finish()
else
local repl = require("core.repl")
repl:enter()
end
-- vim: ft=lua