Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dd: should error on count=B but doesn't #5904

Closed
jfinkels opened this issue Jan 28, 2024 · 2 comments · Fixed by #5920
Closed

dd: should error on count=B but doesn't #5904

jfinkels opened this issue Jan 28, 2024 · 2 comments · Fixed by #5920
Labels

Comments

@jfinkels
Copy link
Collaborator

jfinkels commented Jan 28, 2024

Coreutils dd:

$ : | dd count=B
dd: invalid number: ‘B’

uutils dd:

$ : | ./target/debug/dd count=B
0+0 records in
0+0 records out
0 bytes copied, 2.9087e-04 s, 0.0 B/s

This is from the GNU test suite file tests/dd/bytes.sh.

@sudhackar
Copy link
Contributor

sudhackar commented Jan 30, 2024

This root-causes to

We could check if this is empty and bailout but there's other utils depending on this behaviou


failures:
    test_df::test_block_size_with_suffix
....

test result: FAILED. 2631 passed; 14 failed; 29 ignored; 0 measured; 0 filtered out; finished in 13.73s

There's a test that specifically checks for this

#[test]
fn test_block_size_with_suffix() {
    fn get_header(block_size: &str) -> String {
        let output = new_ucmd!()
            .args(&["-B", block_size, "--output=size"])
            .succeeds()
            .stdout_move_str();
        output.lines().next().unwrap().trim().to_string()
    }

    assert_eq!(get_header("K"), "1K-blocks");
    assert_eq!(get_header("M"), "1M-blocks");
    assert_eq!(get_header("G"), "1G-blocks");
    assert_eq!(get_header("1K"), "1K-blocks");
    assert_eq!(get_header("1M"), "1M-blocks");
    assert_eq!(get_header("1G"), "1G-blocks");
    assert_eq!(get_header("1KiB"), "1K-blocks");
    assert_eq!(get_header("1MiB"), "1M-blocks");
    assert_eq!(get_header("1GiB"), "1G-blocks");
    assert_eq!(get_header("1KB"), "1kB-blocks");
    assert_eq!(get_header("1MB"), "1MB-blocks");
    assert_eq!(get_header("1GB"), "1GB-blocks");
}

@tertsdiepraam
Copy link
Member

It could be another field on the Parser struct in that file that only dd sets to true.

@cakebaker cakebaker linked a pull request Jan 30, 2024 that will close this issue
sylvestre added a commit that referenced this issue Jan 30, 2024
dd: fail on missing number in count, fix #5904
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants