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

dd: allow B as a suffix for count, seek, and skip

Allow uppercase "B" on its own as a unit specifier for the `count`,
`seek`, and `skip` arguments to `dd`.

For example,

    $ printf "abcdef" | dd count=3B status=none
    abc
This commit is contained in:
Jeffrey Finkelstein 2022-11-18 20:27:42 -05:00
parent 847378f8d2
commit 701550d76b
3 changed files with 38 additions and 2 deletions

View file

@ -1295,3 +1295,33 @@ fn test_big_multiplication() {
.fails()
.stderr_contains("invalid number");
}
/// Test for count, seek, and skip given in units of bytes.
#[test]
fn test_bytes_suffix() {
new_ucmd!()
.args(&["count=3B", "status=none"])
.pipe_in("abcdef")
.succeeds()
.stdout_only("abc");
new_ucmd!()
.args(&["skip=3B", "status=none"])
.pipe_in("abcdef")
.succeeds()
.stdout_only("def");
new_ucmd!()
.args(&["iseek=3B", "status=none"])
.pipe_in("abcdef")
.succeeds()
.stdout_only("def");
new_ucmd!()
.args(&["seek=3B", "status=none"])
.pipe_in("abcdef")
.succeeds()
.stdout_only("\0\0\0abcdef");
new_ucmd!()
.args(&["oseek=3B", "status=none"])
.pipe_in("abcdef")
.succeeds()
.stdout_only("\0\0\0abcdef");
}