-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.lua
41 lines (35 loc) · 1.11 KB
/
run.lua
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
local fs = require("filesystem")
local su = require("superUtiles")
local shell = require("shell")
local event = require("event")
local serialization = require("serialization")
-----------------------------------
local args = shell.parse(...)
local arg = {table.unpack(args, 2, #args)}
-----------------------------------
if args[1] then
local data = assert(su.getFile(args[1]))
data = su.modProgramm(data)
local code = assert(load(data))
os.setenv("_", args[1])
local out = {xpcall(code, debug.traceback, table.unpack(arg))}
for i = 1, #out do
if type(out[i]) == "table" then
local ok, value = pcall(serialization.serialize, out[i])
if ok then
out[i] = value
else
out[i] = tostring(out[i])
end
else
out[i] = tostring(out[i])
end
end
out = table.concat(out, "\n")
local filename = os.tmpname()
su.saveFile(filename, out)
shell.execute("view", _ENV, filename)
shell.execute("rm", _ENV, filename)
else
print("path ...")
end