Skip to content

Commit

Permalink
shred: simplify the code
Browse files Browse the repository at this point in the history
The formatting directive {:2.0} will handle both cases (single-digit and double-digit numbers)
by ensuring at least two characters wide with no decimal places
  • Loading branch information
sylvestre committed Mar 23, 2024
1 parent 88ff42e commit 322c2b4
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions src/uu/shred/src/shred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,23 +477,13 @@ fn wipe_file(
for (i, pass_type) in pass_sequence.into_iter().enumerate() {
if verbose {
let pass_name = pass_name(&pass_type);
if total_passes < 10 {
show_error!(
"{}: pass {}/{} ({})...",
path.maybe_quote(),
i + 1,
total_passes,
pass_name
);
} else {
show_error!(
"{}: pass {:2.0}/{:2.0} ({})...",
path.maybe_quote(),
i + 1,
total_passes,
pass_name
);
}
show_error!(
"{}: pass {:2}/{} ({})...",
path.maybe_quote(),
i + 1,
total_passes,
pass_name
);
}
// size is an optional argument for exactly how many bytes we want to shred
// Ignore failed writes; just keep trying
Expand Down

0 comments on commit 322c2b4

Please sign in to comment.