1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

dd: correct order and phrasing of truncated record

Place the "truncated records" line below the "records out" line in the
status report produced by `dd` and properly handle the singularization
of the word "record" in the case of 1 truncated record. This matches
the behavior of GNU `dd`.

For example

    $ printf "ab" | dd cbs=1 conv=block status=noxfer > /dev/null
    0+1 records in
    0+1 records out
    1 truncated record

    $ printf "ab\ncd\n" | dd cbs=1 conv=block status=noxfer > /dev/null
    0+1 records in
    0+1 records out
    2 truncated records
This commit is contained in:
Jeffrey Finkelstein 2022-02-17 22:35:30 -05:00
parent 4719717e33
commit 766c85fb5e
2 changed files with 21 additions and 3 deletions

View file

@ -1079,3 +1079,19 @@ fn test_skip_zero() {
.no_stdout()
.stderr_is("0+0 records in\n0+0 records out\n");
}
#[test]
fn test_truncated_record() {
new_ucmd!()
.args(&["cbs=1", "conv=block", "status=noxfer"])
.pipe_in("ab")
.succeeds()
.stdout_is("a")
.stderr_is("0+1 records in\n0+1 records out\n1 truncated record\n");
new_ucmd!()
.args(&["cbs=1", "conv=block", "status=noxfer"])
.pipe_in("ab\ncd\n")
.succeeds()
.stdout_is("ac")
.stderr_is("0+1 records in\n0+1 records out\n2 truncated records\n");
}