From 7007a2c9943c6ee3a1476da6eed8bc74eac18648 Mon Sep 17 00:00:00 2001 From: Matthieu Jolimaitre Date: Wed, 15 May 2024 00:33:54 +0200 Subject: [PATCH] implement cat script --- cc-tweaked/scripts/cat.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cc-tweaked/scripts/cat.lua b/cc-tweaked/scripts/cat.lua index d92e5af..b3e0820 100644 --- a/cc-tweaked/scripts/cat.lua +++ b/cc-tweaked/scripts/cat.lua @@ -1,8 +1,17 @@ -local arg1, arg2, arg3 = ... +local path = ... local function main() - print("arg1", arg1, "arg2", arg2, "arg3", arg3) - local file = fs.open() + if path == nil then + print("Usage: cat ") + 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 main()