cat now inserts a newline at the end of the file if there isn't one already
This commit is contained in:
@@ -15,11 +15,16 @@ for _, file in pairs(args) do
|
|||||||
terminal.write("\27[91mCan't open " .. file .. "\27[0m\n")
|
terminal.write("\27[91mCan't open " .. file .. "\27[0m\n")
|
||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
|
local enddata
|
||||||
while true do
|
while true do
|
||||||
local data = handle:read(math.huge or math.maxinteger)
|
local data = handle:read(math.huge or math.maxinteger)
|
||||||
if data == nil then break end
|
if data == nil then break end
|
||||||
terminal.write(data)
|
terminal.write(data)
|
||||||
|
enddata = data
|
||||||
end
|
end
|
||||||
handle:close()
|
handle:close()
|
||||||
|
if string.sub(enddata, -1, -1) ~= "\n" then
|
||||||
|
print("")
|
||||||
|
end
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user