mirror of https://github.com/Hilbis/Hilbish
Merge 0a225ac847
into 40c3cecabb
commit
9f53203431
|
@ -1,5 +1,9 @@
|
||||||
# 🎀 Changelog
|
# 🎀 Changelog
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
### Added
|
||||||
|
- `cat` command now reads files in chunks, allowing for reading large files
|
||||||
|
|
||||||
## [2.2.2] - 2024-04-16
|
## [2.2.2] - 2024-04-16
|
||||||
### Fixed
|
### Fixed
|
||||||
- Line refresh fixes (less flicker)
|
- Line refresh fixes (less flicker)
|
||||||
|
|
|
@ -9,6 +9,8 @@ commander.register('cat', function(args, sinks)
|
||||||
usage: cat [file]...]]
|
usage: cat [file]...]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local chunk_size = 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)
|
||||||
if f == nil then
|
if f == nil then
|
||||||
|
@ -17,7 +19,12 @@ usage: cat [file]...]]
|
||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
|
|
||||||
sinks.out:writeln(f:read '*a')
|
while true do
|
||||||
|
local block = f:read(chunk_size)
|
||||||
|
if not block then break end
|
||||||
|
sinks.out:write(block)
|
||||||
|
end
|
||||||
|
sinks.out:writeln("")
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
io.flush()
|
io.flush()
|
||||||
|
|
Loading…
Reference in New Issue