Compare commits
No commits in common. "05208810d3984cfac773bc6286aa8ead2bd031f9" and "39ea9c1a18cb90eda64bd7ae3bf5dfda9f2e5c6f" have entirely different histories.
05208810d3
...
39ea9c1a18
@ -1,4 +1,3 @@
|
|||||||
local serial = require "serialization"
|
|
||||||
local shell = {}
|
local shell = {}
|
||||||
shell.include = {"shutil"}
|
shell.include = {"shutil"}
|
||||||
local function shindex(self,k)
|
local function shindex(self,k)
|
||||||
@ -26,17 +25,8 @@ function shell.interactive()
|
|||||||
local rt = {pcall(f)}
|
local rt = {pcall(f)}
|
||||||
local rs = table.remove(rt,1)
|
local rs = table.remove(rt,1)
|
||||||
for k,v in pairs(rt) do
|
for k,v in pairs(rt) do
|
||||||
if type(v) == "table" then
|
|
||||||
local w, s = pcall(serial.serialize,v)
|
|
||||||
if w then
|
|
||||||
print(s)
|
|
||||||
else
|
|
||||||
print(tostring(v))
|
print(tostring(v))
|
||||||
end
|
end
|
||||||
else
|
|
||||||
print(tostring(v))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
buffer = {}
|
buffer = {}
|
||||||
|
|
||||||
function buffer.new(mode, stream) -- create a new buffer in mode *mode* backed by stream object *stream*
|
function buffer.new(mode, stream)
|
||||||
local result = {
|
local result = {
|
||||||
mode = {},
|
mode = {},
|
||||||
stream = stream,
|
stream = stream,
|
||||||
@ -23,6 +23,7 @@ function buffer.new(mode, stream) -- create a new buffer in mode *mode* backed b
|
|||||||
return setmetatable(result, metatable)
|
return setmetatable(result, metatable)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function badFileDescriptor()
|
local function badFileDescriptor()
|
||||||
return nil, "bad file descriptor"
|
return nil, "bad file descriptor"
|
||||||
end
|
end
|
||||||
@ -43,7 +44,7 @@ function buffer:flush()
|
|||||||
if reason then
|
if reason then
|
||||||
return nil, reason
|
return nil, reason
|
||||||
else
|
else
|
||||||
return badFileDescriptor()
|
return nil, "bad file descriptor"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -104,6 +105,7 @@ function buffer:read(...)
|
|||||||
self.bufferRead = sub(self.bufferRead, left + 1)
|
self.bufferRead = sub(self.bufferRead, left + 1)
|
||||||
until len(buffer) == n
|
until len(buffer) == n
|
||||||
|
|
||||||
|
--kernel.io.println("buffer read: "..tostring(buffer))
|
||||||
return buffer
|
return buffer
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -358,7 +360,7 @@ end
|
|||||||
|
|
||||||
function buffer:write(...)
|
function buffer:write(...)
|
||||||
if self.closed then
|
if self.closed then
|
||||||
return badFileDescriptor()
|
return nil, "bad file descriptor"
|
||||||
end
|
end
|
||||||
local args = table.pack(...)
|
local args = table.pack(...)
|
||||||
for i = 1, args.n do
|
for i = 1, args.n do
|
||||||
|
@ -12,7 +12,7 @@ function os.spawnfile(p,n,...) -- spawns a new process from file *p* with name *
|
|||||||
return os.spawn(function() local res={pcall(loadfile(p), table.unpack(tA))} computer.pushSignal("process_finished", os.pid(), table.unpack(res)) dprint(table.concat(res)) end,n or p)
|
return os.spawn(function() local res={pcall(loadfile(p), table.unpack(tA))} computer.pushSignal("process_finished", os.pid(), table.unpack(res)) dprint(table.concat(res)) end,n or p)
|
||||||
end
|
end
|
||||||
_G.package = {}
|
_G.package = {}
|
||||||
package.loaded = {computer=computer,component=component,fs=fs,buffer=buffer}
|
package.loaded = {computer=computer,component=component,fs=fs}
|
||||||
function require(f) -- searches for a library with name *f* and returns what the library returns, if possible
|
function require(f) -- searches for a library with name *f* and returns what the library returns, if possible
|
||||||
if not package.loaded[f] then
|
if not package.loaded[f] then
|
||||||
local lib = os.getenv("LIB") or "/boot/lib"
|
local lib = os.getenv("LIB") or "/boot/lib"
|
||||||
|
Loading…
Reference in New Issue
Block a user