mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
hashsum: ignore empty lines in --check
This commit is contained in:
parent
beb7395c84
commit
94f5e82dbd
2 changed files with 22 additions and 0 deletions
|
@ -692,6 +692,10 @@ where
|
|||
Ok(l) => l,
|
||||
Err(e) => return Err(e.map_err_context(|| "failed to read file".to_string())),
|
||||
};
|
||||
if line.is_empty() {
|
||||
// empty line, skip it
|
||||
continue;
|
||||
}
|
||||
let (ck_filename, sum, binary_check) = match gnu_re.captures(&line) {
|
||||
Some(caps) => {
|
||||
handle_captures(&caps, &bytes_marker, &mut bsd_reversed, &mut gnu_re)?
|
||||
|
|
|
@ -457,6 +457,24 @@ fn test_with_escape_filename_zero_text() {
|
|||
assert!(stdout.contains("a\nb"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_check_empty_line() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
at.touch("f");
|
||||
at.write(
|
||||
"in.md5",
|
||||
"d41d8cd98f00b204e9800998ecf8427e f\n\nd41d8cd98f00b204e9800998ecf8427e f\ninvalid\n\n",
|
||||
);
|
||||
scene
|
||||
.ccmd("md5sum")
|
||||
.arg("--check")
|
||||
.arg(at.subdir.join("in.md5"))
|
||||
.fails()
|
||||
.stderr_contains("WARNING: 1 line is improperly formatted");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(windows))]
|
||||
fn test_check_with_escape_filename() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue