cat now inserts a newline at the end of the file if there isn't one already

This commit is contained in:
mcplayer3
2026-06-19 15:03:45 +10:00
parent 9b9c005194
commit a3e0ec64ae
+5
View File
@@ -15,11 +15,16 @@ for _, file in pairs(args) do
terminal.write("\27[91mCan't open " .. file .. "\27[0m\n")
goto continue
end
local enddata
while true do
local data = handle:read(math.huge or math.maxinteger)
if data == nil then break end
terminal.write(data)
enddata = data
end
handle:close()
if string.sub(enddata, -1, -1) ~= "\n" then
print("")
end
::continue::
end