implement cat script
This commit is contained in:
parent
62cd230d5b
commit
7007a2c994
1 changed files with 12 additions and 3 deletions
|
@ -1,8 +1,17 @@
|
||||||
local arg1, arg2, arg3 = ...
|
local path = ...
|
||||||
|
|
||||||
local function main()
|
local function main()
|
||||||
print("arg1", arg1, "arg2", arg2, "arg3", arg3)
|
if path == nil then
|
||||||
local file = fs.open()
|
print("Usage: cat <path>")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local file = fs.open(path, "r")
|
||||||
|
if file == nil then
|
||||||
|
print("No such file:", path)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local content = file.readAll()
|
||||||
|
print(content)
|
||||||
end
|
end
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue