3c087aaddf
stopped component.invoke from throwing a cryptic error, and ported over cat, cd, clear, cp, edit, ls, lsdrv, and mkdir
22 lines
516 B
Lua
22 lines
516 B
Lua
local files = {...}
|
|
local shell = require("shell")
|
|
local fs = require("filesystem")
|
|
if not files or not files[1] then
|
|
shell.run("help cat")
|
|
return
|
|
end
|
|
for _, file in ipairs(files) do
|
|
if file:sub(1, 1) ~= "/" then
|
|
file = fs.concat(shell.getWorkingDirectory(), file)
|
|
end
|
|
if not fs.exists(file) then
|
|
print("\27[91mFile does not exist.")
|
|
end
|
|
local handle = fs.open(file, "r")
|
|
local data
|
|
repeat
|
|
data = handle:read(math.huge or math.maxinteger)
|
|
terminal.write(data)
|
|
until not data
|
|
end
|