From 3b607f1c7c3ca14960735c3f8a917be5f5e35062 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 24 Jun 2024 22:03:59 +0200 Subject: [PATCH] cksum: move the code where needed --- src/uu/hashsum/src/hashsum.rs | 43 ++++++++++++++++------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index 1e73ffab2..a1e1f0781 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -207,16 +207,9 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> { binary_flag_default }; let check = matches.get_flag("check"); - let tag = matches.get_flag("tag"); - let nonames = *matches - .try_get_one("no-names") - .unwrap_or(None) - .unwrap_or(&false); let status = matches.get_flag("status"); let quiet = matches.get_flag("quiet") || status; - //let strict = matches.get_flag("strict"); let warn = matches.get_flag("warn") && !status; - let zero = matches.get_flag("zero"); let ignore_missing = matches.get_flag("ignore-missing"); if ignore_missing && !check { @@ -224,22 +217,6 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> { return Err(ChecksumError::IgnoreNotCheck.into()); } - let opts = Options { - algoname: algo.name, - digest: (algo.create_fn)(), - output_bits: algo.bits, - binary, - //check, - tag, - nonames, - //status, - //quiet, - //strict, - //warn, - zero, - //ignore_missing, - }; - if check { let text_flag = matches.get_flag("text"); let binary_flag = matches.get_flag("binary"); @@ -270,6 +247,26 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> { ); } + let nonames = *matches + .try_get_one("no-names") + .unwrap_or(None) + .unwrap_or(&false); + let zero = matches.get_flag("zero"); + + let opts = Options { + algoname: algo.name, + digest: (algo.create_fn)(), + output_bits: algo.bits, + binary, + tag: matches.get_flag("tag"), + nonames, + //status, + //quiet, + //warn, + zero, + //ignore_missing, + }; + // Show the hashsum of the input match matches.get_many::(options::FILE) { Some(files) => hashsum(opts, files.map(|f| f.as_os_str())),