mirror of
https://github.com/uutils/coreutils
synced 2024-12-24 03:53:16 +00:00
bc9db289e8
Add some abstractions to simplify the `rbuf_but_last_n_lines()` function, which implements the "take all but the last `n` lines" functionality of the `head` program. This commit adds - `RingBuffer`, a fixed-size ring buffer, - `ZLines`, an iterator over zero-terminated "lines", - `TakeAllBut`, an iterator over all but the last `n` elements of an iterator. These three together make the implementation of `rbuf_but_last_n_lines()` concise. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |
Notes / ToDO
- Rudimentary tail implementation.
Missing features:
Flags with features
--max-unchanged-stats
: with--follow=name
, reopen a FILE which has not changed size after N (default 5) iterations to see if it has been unlinked or renamed (this is the usual case of rotated log files). With inotify, this option is rarely useful.--retry
: keep trying to open a file even when it is or becomes inaccessible; useful when follow‐ing by name, i.e., with--follow=name
Others
- The current implementation does not handle
-
as an alias for stdin.
Possible optimizations:
- Don't read the whole file if not using
-f
and input is regular file. Read in chunks from the end going backwards, reading each individual chunk forward.