summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-10-11 21:49:37 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-10-11 21:49:37 +0800
commitd3d0f7aa6732b637d661d1ede2fbf1f293a2abc8 (patch)
tree0935e8c28d7a3a419dd33be03f08f6e6a492702f
parent88d6cc00d61298565017f5e18be2960dfcc12e11 (diff)
downloadlua-language-server-d3d0f7aa6732b637d661d1ede2fbf1f293a2abc8.zip
Revert "revert bootstrap for now"
This reverts commit 88d6cc00d61298565017f5e18be2960dfcc12e11.
-rw-r--r--make/bootstrap.lua37
1 files changed, 26 insertions, 11 deletions
diff --git a/make/bootstrap.lua b/make/bootstrap.lua
index 77f1a4d0..cf908b67 100644
--- a/make/bootstrap.lua
+++ b/make/bootstrap.lua
@@ -1,25 +1,39 @@
+local main
local i = 1
-while true do
+while arg[i] do
if arg[i] == '-E' then
elseif arg[i] == '-e' then
i = i + 1
local expr = assert(arg[i], "'-e' needs argument")
assert(load(expr, "=(command line)"))()
- else
- break
+ -- TODO
+ return
+ elseif not main and arg[i]:sub(1, 1) ~= '-' then
+ main = i
end
- i = i + 1
end
-if arg[i] == nil then
- return
+if main then
+ for i = -1, -999, -1 do
+ if not arg[i] then
+ for j = i + 1, -1 do
+ arg[j - main + 1] = arg[j]
+ end
+ break
+ end
+ end
+ for j = 1, #arg do
+ arg[j - main] = arg[j]
+ end
+ for j = #arg - main + 1, #arg do
+ arg[j] = nil
+ end
+else
+ arg[0] = 'main.lua'
end
-for j = -1, #arg do
- arg[j - i] = arg[j]
-end
-for j = #arg - i + 1, #arg do
- arg[j] = nil
+for k, v in pairs(arg) do
+ print(k, v)
end
local root; do
@@ -38,4 +52,5 @@ package.path = table.concat({
root .. "/script/?.lua",
root .. "/script/?/init.lua",
}, ";")
+
assert(loadfile(arg[0]))(table.unpack(arg))