From 6d89f96d860416a34c03c37021caca40b6c8a6a9 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 23 Mar 2024 10:21:20 +0100 Subject: [PATCH] shred: only run zero when the file isn't empty --- src/uu/shred/src/shred.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/uu/shred/src/shred.rs b/src/uu/shred/src/shred.rs index 5265f29f05f..d023b62107a 100644 --- a/src/uu/shred/src/shred.rs +++ b/src/uu/shred/src/shred.rs @@ -460,10 +460,11 @@ fn wipe_file( pass_sequence[i * (n_passes - 1) / (n_random - 1)] = PassType::Random; } } - } - // --zero specifies whether we want one final pass of 0x00 on our file - if zero { - pass_sequence.push(PassType::Pattern(PATTERNS[0])); + + // --zero specifies whether we want one final pass of 0x00 on our file + if zero { + pass_sequence.push(PassType::Pattern(PATTERNS[0])); + } } let total_passes = pass_sequence.len();