Skip to content

Commit

Permalink
hashsum: change debug to display format with --tag
Browse files Browse the repository at this point in the history
  • Loading branch information
tertsdiepraam committed Aug 28, 2023
1 parent bd82d67 commit 8d088fa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/uu/hashsum/src/hashsum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ where
)
.map_err_context(|| "failed to read input".to_string())?;
if options.tag {
println!("{} ({:?}) = {}", options.algoname, filename.display(), sum);
println!("{} ({}) = {}", options.algoname, filename.display(), sum);
} else if options.nonames {
println!("{sum}");
} else if options.zero {
Expand Down
16 changes: 16 additions & 0 deletions tests/by-util/test_hashsum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,19 @@ fn test_check_md5sum_mixed_format() {
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}

#[test]
fn tag_and_filename_with_space() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;

at.write("foo bar", "foo bar\n");
scene
.ccmd("sha256sum")
.arg("--tag")
.arg("foo bar")
.succeeds()
.stdout_is(
"SHA256 (foo bar) = 1f2ec52b774368781bed1d1fb140a92e0eb6348090619c9291f9a5a3c8e8d151\n",
);
}

0 comments on commit 8d088fa

Please sign in to comment.