dd: do not show zero multiplier warning when zero is the multiplicand (#11673)

* dd: do not show zero multiplier warning when zero is the multiplicand

* tests/dd: test zero multiplier warning when zero is the multiplicand
This commit is contained in:
Ibrahim Burak Yorulmaz
2026-04-06 08:16:40 +02:00
committed by GitHub
parent fca0d0416c
commit db9a111c18
2 changed files with 9 additions and 2 deletions
+2 -2
View File
@@ -524,8 +524,8 @@ pub fn parse_bytes_with_opt_multiplier(s: &str) -> Result<u64, ParseError> {
parse_bytes_no_x(s, parts[0])
} else {
let mut total: u64 = 1;
for part in parts {
if part == "0" {
for (i, part) in parts.iter().enumerate() {
if *part == "0" && i != parts.len() - 1 {
show_zero_multiplier_warning();
}
let num = parse_bytes_no_x(s, part)?;
+7
View File
@@ -263,6 +263,13 @@ fn test_zero_multiplier_warning() {
.succeeds()
.no_stdout()
.stderr_contains("warning: '0x' is a zero multiplier; use '00x' if that is intended");
new_ucmd!()
.args(&[format!("{arg}=0x0x0").as_str(), "status=none"])
.pipe_in("")
.succeeds()
.no_stdout()
.stderr_is("dd: warning: '0x' is a zero multiplier; use '00x' if that is intended\ndd: warning: '0x' is a zero multiplier; use '00x' if that is intended\n");
}
}