mirror of https://github.com/Hilbis/Hilbish
fix: cat doesn't print extra newline at end of each file
parent
229fe4c6bb
commit
c997a0b9ae
|
@ -1,6 +1,9 @@
|
||||||
# 🎀 Changelog
|
# 🎀 Changelog
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
### Fixed
|
||||||
|
- `cat` command no longer prints extra newline at end of each file
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- `cat` command now reads files in chunks, allowing for reading large files
|
- `cat` command now reads files in chunks, allowing for reading large files
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ commander.register('cat', function(args, sinks)
|
||||||
usage: cat [file]...]]
|
usage: cat [file]...]]
|
||||||
end
|
end
|
||||||
|
|
||||||
local chunk_size = 2^13 -- 8K buffer size
|
local chunkSize = 2^13 -- 8K buffer size
|
||||||
|
|
||||||
for _, fName in ipairs(args) do
|
for _, fName in ipairs(args) do
|
||||||
local f = io.open(fName)
|
local f = io.open(fName)
|
||||||
|
@ -20,11 +20,10 @@ usage: cat [file]...]]
|
||||||
end
|
end
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
local block = f:read(chunk_size)
|
local block = f:read(chunkSize)
|
||||||
if not block then break end
|
if not block then break end
|
||||||
sinks.out:write(block)
|
sinks.out:write(block)
|
||||||
end
|
end
|
||||||
sinks.out:writeln("")
|
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
io.flush()
|
io.flush()
|
||||||
|
|
Loading…
Reference in New Issue