From 7a46ea371f852c2e62520ff9620efc2c73c51ba9 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 18 May 2024 10:03:28 +0200 Subject: [PATCH 1/3] hashsum: rename the variable for something more explicit --- src/uu/hashsum/src/hashsum.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index 39b5a0a07..961d4bb55 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -327,7 +327,7 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> { // least somewhat better from a user's perspective. let matches = command.try_get_matches_from(args)?; - let (name, algo, bits) = detect_algo(&binary_name, &matches)?; + let (algoname, algo, bits) = detect_algo(&binary_name, &matches)?; let binary = if matches.get_flag("binary") { true @@ -355,7 +355,7 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> { } let opts = Options { - algoname: name, + algoname, digest: algo, output_bits: bits, binary, From a9a11f486ecf632f0697228ef54abcac56a340ff Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 18 May 2024 10:04:48 +0200 Subject: [PATCH 2/3] hashsum: rename the blake2b algo with --tag + manage the different length --- src/uu/hashsum/src/hashsum.rs | 17 +++++++++++------ tests/by-util/test_hashsum.rs | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index 961d4bb55..71923009e 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -59,7 +59,7 @@ struct Options { /// greater than 512. fn create_blake2b(matches: &ArgMatches) -> UResult<(&'static str, Box, usize)> { match matches.get_one::("length") { - Some(0) | None => Ok(("BLAKE2", Box::new(Blake2b::new()) as Box, 512)), + Some(0) | None => Ok(("BLAKE2b", Box::new(Blake2b::new()) as Box, 512)), Some(length_in_bits) => { if *length_in_bits > 512 { return Err(USimpleError::new( @@ -71,7 +71,7 @@ fn create_blake2b(matches: &ArgMatches) -> UResult<(&'static str, Box Date: Sat, 18 May 2024 10:06:28 +0200 Subject: [PATCH 3/3] hashsum: simplify the println --- src/uu/hashsum/src/hashsum.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index 71923009e..892f3a15b 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -805,9 +805,9 @@ where println!("{sum}"); } else if options.zero { // with zero, we don't escape the filename - print!("{} {}{}\0", sum, binary_marker, filename.display()); + print!("{sum} {binary_marker}{}\0", filename.display()); } else { - println!("{}{} {}{}", prefix, sum, binary_marker, escaped_filename); + println!("{prefix}{sum} {binary_marker}{escaped_filename}"); } } if bad_format > 0 && failed_cksum == 0 && correct_format == 0 && !options.status {