Skip to content

Commit 8b99d80

Browse files
committed
shred: correctly print zero-byte pass in verbose mode
Fixes #7798.
1 parent f92ee6a commit 8b99d80

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/uu/shred/src/shred.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ fn get_size(size_str_opt: Option<String>) -> Option<u64> {
376376
fn pass_name(pass_type: &PassType) -> String {
377377
match pass_type {
378378
PassType::Random => String::from("random"),
379-
PassType::Pattern(Pattern::Single(byte)) => format!("{byte:x}{byte:x}{byte:x}"),
380-
PassType::Pattern(Pattern::Multi([a, b, c])) => format!("{a:x}{b:x}{c:x}"),
379+
PassType::Pattern(Pattern::Single(byte)) => format!("{byte:02x}{byte:02x}{byte:02x}"),
380+
PassType::Pattern(Pattern::Multi([a, b, c])) => format!("{a:02x}{b:02x}{c:02x}"),
381381
}
382382
}
383383

tests/by-util/test_shred.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,14 @@ fn test_shred_fail_no_perm() {
208208
.fails()
209209
.stderr_contains("Couldn't rename to");
210210
}
211+
212+
#[test]
213+
fn test_shred_verbose_pass_single_0_byte_name() {
214+
let (at, mut ucmd) = at_and_ucmd!();
215+
let file = "foo";
216+
at.write(file, "non-empty");
217+
ucmd.arg("-vn200")
218+
.arg(file)
219+
.succeeds()
220+
.stderr_contains("/1000 (000000)...\n");
221+
}

0 commit comments

Comments
 (0)