diff --git a/Capy64/Assets/Lua/bin/shell.lua b/Capy64/Assets/Lua/bin/shell.lua index 353589b..81d2654 100644 --- a/Capy64/Assets/Lua/bin/shell.lua +++ b/Capy64/Assets/Lua/bin/shell.lua @@ -1,6 +1,7 @@ local term = require("term") local colors = require("colors") local fs = require("fs") +local machine = require("machine") local exit = false local shell = {} @@ -10,9 +11,13 @@ shell.homePath = "/home" local currentDir = shell.homePath -local function buildEnvironment() +local function buildEnvironment(path, args) + local arg = { table.unpack(args, 2) } + arg[0] = path + return setmetatable({ shell = shell, + arg = arg }, { __index = _G }) end @@ -76,7 +81,7 @@ function shell.run(...) return false end - local env = buildEnvironment() + local env = buildEnvironment(command, args) local func, err = loadfile(path, "t", env) @@ -105,6 +110,8 @@ end local history = {} local lastExecSuccess = true while not exit do + machine.setRPC(os.version(), "On shell") + term.setBackground(colors.black) term.setForeground(colors.white) io.write(":") @@ -130,6 +137,7 @@ while not exit do end if line:match("%S") then + machine.setRPC(os.version(), "Running: " .. line) lastExecSuccess = shell.run(line) end end diff --git a/Capy64/Assets/Lua/init.lua b/Capy64/Assets/Lua/init.lua index cd1a73a..2bad296 100644 --- a/Capy64/Assets/Lua/init.lua +++ b/Capy64/Assets/Lua/init.lua @@ -1,3 +1,5 @@ +local version = "0.0.2" + print("Starting CapyOS") local term = require("term") @@ -20,7 +22,7 @@ local function showError(err) end function os.version() - return "CapyOS 0.0.2" + return "CapyOS " .. version end term.setSize(51, 19) @@ -30,18 +32,16 @@ term.setPos(1, 1) term.write(_HOST) local files = fs.list("/boot/autorun") -for k, v in ipairs(files) do - local func, err = loadfile("/boot/autorun/" .. v) +for i = 1, #files do + local func, err = loadfile("/boot/autorun/" .. files[i]) if not func then showError(err) break end local ok, err = pcall(func) - if not ok then showError(debug.traceback(err)) - break end end