Commit graph

16 commits

Author SHA1 Message Date
Jan Scheer
cc659c8572 Merge branch 'master' of github.com:uutils/coreutils into refactoring_parse_size 2021-06-01 12:35:48 +02:00
Jan Scheer
3c7175f00d head/tail: add fixes and tests for bytes/lines NUM arg (undocumented sign)
* change tail bytes/lines clap parsing to fix posix override behavior
* change tail bytes/lines NUM parsing logic to be consistent with head
2021-06-01 12:17:11 +02:00
Jan Scheer
84f2bff778 head: use "parse_size" from uucore 2021-06-01 09:30:43 +02:00
Roy Ivy III
4e20dedf58 tests ~ refactor/polish spelling (comments, names, and exceptions) 2021-05-31 08:23:57 -05:00
Jan Scheer
3aeccfd802 fix a lot of clippy warnings 2021-05-29 15:11:22 +02:00
Jeffrey Finkelstein
bc9db289e8 head: add abstractions for "all but last n lines"
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.
2021-05-22 23:56:48 -04:00
Jeffrey Finkelstein
eeef8290df head: display errors for each input file
Change the behavior of `head` to display an error for each problematic
file, instead of displaying an error message for the first problematic
file and terminating immediately at that point. This change now matches
the behavior of GNU `head`.

Before this commit, the first error caused the program to terminate
immediately:

    $ head a b c
    head: error: head: cannot open 'a' for reading: No such file or directory

After this commit:

    $ head a b c
    head: cannot open 'a' for reading: No such file or directory
    head: cannot open 'b' for reading: No such file or directory
    head: cannot open 'c' for reading: No such file or directory
2021-05-17 08:19:47 -04:00
Jeffrey Finkelstein
659bf58a4c head: print headings when reading multiple files
Fix a bug in which `head` failed to print headings for `stdin` inputs
when reading from multiple files, and fix another bug in which `head`
failed to print a blank line between the contents of a file and the
heading for the next file when reading multiple files. The output now
matches that of GNU `head`.
2021-05-16 12:03:10 -04:00
Jan Scheer
646c6cacbc refactor tests (#1982) 2021-04-23 02:28:46 +02:00
Mikadore
8320b1ec5f
Rewrote head (#1911)
See https://github.com/uutils/coreutils/pull/1911
for the details
2021-03-29 13:08:48 +02:00
Yagiz Degirmenci
6c98415340
fix(head): check the whether file exists before unwrap (#1858)
closes https://github.com/uutils/coreutils/issues/1800
2021-03-21 21:27:44 +01:00
Peter Sherman
13e61c3234 head: add support for -z/--zero-terminated 2021-03-15 15:56:11 +00:00
nicoo
b0ac07296f
head: Ignore known-failing tests introduced in #1579 (#1586)
This caused tests to fail on all unrelated work.
In particular, CI went red fall all pull requests.
2020-08-09 18:51:04 +02:00
Roy Ivy III
b38abbce5e tests: (head) cargo fmt 2020-08-08 23:04:29 -05:00
Chad Brewbaker
c1f518e586 Adding failing GNU head tests (#1579)
Co-authored-by: Chad Brewbaker <chad@flyingdogsolutions.com>
2020-08-08 22:26:49 -05:00
Roy Ivy III
de0375f909 tests ~ reorganize tests 2020-06-01 18:30:04 -05:00
Renamed from tests/test_head.rs (Browse further)