Started making a better version of edit

This commit is contained in:
mcplayer3
2026-06-07 00:12:25 +10:00
parent 8c33ee0eb9
commit f81e9089d3
+36
View File
@@ -0,0 +1,36 @@
local fs = require("filesystem")
local shell = require("shell")
local args = {...}
local file = args[1]
if not file then
print("\x1b[91mEnter a file name.")
return
end
if fs.isDirectory(file) then
print("\x1b[91mThe specified file is a directory.")
return
end
if file:sub(1, 1) ~= "/" then
file = fs.concat(shell.getWorkingDirectory(), file)
end
local data = ""
if fs.exists(file) then
local handle = fs.open(file)
local tmpdata
repeat
tmpdata = handle:read(math.huge or math.maxinteger)
data = data .. (tmpdata or "")
until not tmpdata
end
local lines = {}
for line in data:gmatch("[^\r\n]+") do
table.insert(lines, line)
end
for _, line in ipairs(lines) do
print(line)
end