Compare commits
2 Commits
39ea9c1a18
...
05208810d3
Author | SHA1 | Date | |
---|---|---|---|
05208810d3 | |||
7974ff9702 |
@ -1,3 +1,4 @@
|
||||
local serial = require "serialization"
|
||||
local shell = {}
|
||||
shell.include = {"shutil"}
|
||||
local function shindex(self,k)
|
||||
@ -25,7 +26,16 @@ function shell.interactive()
|
||||
local rt = {pcall(f)}
|
||||
local rs = table.remove(rt,1)
|
||||
for k,v in pairs(rt) do
|
||||
print(tostring(v))
|
||||
if type(v) == "table" then
|
||||
local w, s = pcall(serial.serialize,v)
|
||||
if w then
|
||||
print(s)
|
||||
else
|
||||
print(tostring(v))
|
||||
end
|
||||
else
|
||||
print(tostring(v))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
buffer = {}
|
||||
|
||||
function buffer.new(mode, stream)
|
||||
function buffer.new(mode, stream) -- create a new buffer in mode *mode* backed by stream object *stream*
|
||||
local result = {
|
||||
mode = {},
|
||||
stream = stream,
|
||||
@ -23,7 +23,6 @@ function buffer.new(mode, stream)
|
||||
return setmetatable(result, metatable)
|
||||
end
|
||||
|
||||
|
||||
local function badFileDescriptor()
|
||||
return nil, "bad file descriptor"
|
||||
end
|
||||
@ -44,7 +43,7 @@ function buffer:flush()
|
||||
if reason then
|
||||
return nil, reason
|
||||
else
|
||||
return nil, "bad file descriptor"
|
||||
return badFileDescriptor()
|
||||
end
|
||||
end
|
||||
|
||||
@ -105,7 +104,6 @@ function buffer:read(...)
|
||||
self.bufferRead = sub(self.bufferRead, left + 1)
|
||||
until len(buffer) == n
|
||||
|
||||
--kernel.io.println("buffer read: "..tostring(buffer))
|
||||
return buffer
|
||||
end
|
||||
|
||||
@ -360,7 +358,7 @@ end
|
||||
|
||||
function buffer:write(...)
|
||||
if self.closed then
|
||||
return nil, "bad file descriptor"
|
||||
return badFileDescriptor()
|
||||
end
|
||||
local args = table.pack(...)
|
||||
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)
|
||||
end
|
||||
_G.package = {}
|
||||
package.loaded = {computer=computer,component=component,fs=fs}
|
||||
package.loaded = {computer=computer,component=component,fs=fs,buffer=buffer}
|
||||
function require(f) -- searches for a library with name *f* and returns what the library returns, if possible
|
||||
if not package.loaded[f] then
|
||||
local lib = os.getenv("LIB") or "/boot/lib"
|
||||
|
Loading…
Reference in New Issue
Block a user