mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
hashsum: add --no-names option from official b3sum tool (#3361)
* hashsum: add --no-names option from official b3sum tool The official b3sum tool has a --no-names option for only printing the hashes, omitting the filenames. This is quite handy when used from scripts because it spares the postprocessing with "cut" or "awk". Since the installed b3sum symlink would also serve as a drop-in for the official tool, the --no-names option is expected to exist for compatibility. Add a --no-names option not only for b3sum but for hashsum in general (and maybe GNU coreutils will also feel inspired to add this option). Closes https://github.com/uutils/coreutils/issues/3360
This commit is contained in:
parent
bc7c9c1659
commit
e894e40c56
2 changed files with 22 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
|||
// spell-checker:ignore checkfile
|
||||
// spell-checker:ignore checkfile, nonames
|
||||
macro_rules! get_hash(
|
||||
($str:expr) => (
|
||||
$str.split(' ').collect::<Vec<&str>>()[0]
|
||||
|
@ -29,6 +29,16 @@ macro_rules! test_digest {
|
|||
get_hash!(ts.ucmd().arg(DIGEST_ARG).arg(BITS_ARG).pipe_in_fixture("input.txt").succeeds().no_stderr().stdout_str()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_nonames() {
|
||||
let ts = TestScenario::new("hashsum");
|
||||
// EXPECTED_FILE has no newline character at the end
|
||||
assert_eq!(format!("{0}\n{0}\n", ts.fixtures.read(EXPECTED_FILE)),
|
||||
ts.ucmd().arg(DIGEST_ARG).arg(BITS_ARG).arg("--no-names").arg("input.txt").arg("-").pipe_in_fixture("input.txt")
|
||||
.succeeds().no_stderr().stdout_str()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_check() {
|
||||
let ts = TestScenario::new("hashsum");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue