8000 cksum: Update error and flags handling to improver GNU's match by RenjiSann · Pull Request #7192 · uutils/coreutils · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

cksum: Update error and flags handling to improver GNU's match #7192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/uu/cksum/src/cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ use std::iter;
use std::path::Path;
use uucore::checksum::{
calculate_blake2b_length, detect_algo, digest_reader, perform_checksum_validation,
ChecksumError, ChecksumOptions, ALGORITHM_OPTIONS_BLAKE2B, ALGORIT 8000 HM_OPTIONS_BSD,
ALGORITHM_OPTIONS_CRC, ALGORITHM_OPTIONS_CRC32B, ALGORITHM_OPTIONS_SYSV, SUPPORTED_ALGORITHMS,
ChecksumError, ChecksumOptions, ChecksumVerbose, ALGORITHM_OPTIONS_BLAKE2B,
ALGORITHM_OPTIONS_BSD, ALGORITHM_OPTIONS_CRC, ALGORITHM_OPTIONS_CRC32B, ALGORITHM_OPTIONS_SYSV,
SUPPORTED_ALGORITHMS,
};
use uucore::{
encoding,
Expand Down Expand Up @@ -322,13 +323,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|| iter::once(OsStr::new("-")).collect::<Vec<_>>(),
|files| files.map(OsStr::new).collect::<Vec<_>>(),
);

let verbose = ChecksumVerbose::new(status, quiet, warn);

let opts = ChecksumOptions {
binary: binary_flag,
ignore_missing,
quiet,
status,
strict,
warn,
verbose,
};

return perform_checksum_validation(files.iter().copied(), algo_option, length, opts);
Expand Down Expand Up @@ -462,19 +464,22 @@ pub fn uu_app() -> Command {
.short('w')
.long("warn")
.help("warn about improperly formatted checksum lines")
.action(ArgAction::SetTrue),
.action(ArgAction::SetTrue)
.overrides_with_all([options::STATUS, options::QUIET]),
)
.arg(
Arg::new(options::STATUS)
.long("status")
.help("don't output anything, status code shows success")
.action(ArgAction::SetTrue),
.action(ArgAction::SetTrue)
.overrides_with_all([options::WARN, options::QUIET]),
)
.arg(
Arg::new(options::QUIET)
.long(options::QUIET)
.help("don't print OK for each successfully verified file")
.action(ArgAction::SetTrue),
.action(ArgAction::SetTrue)
.overrides_with_all([options::WARN, options::STATUS]),
)
.arg(
Arg::new(options::IGNORE_MISSING)
Expand Down
17 changes: 11 additions & 6 deletions src/uu/hashsum/src/hashsum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use uucore::checksum::escape_filename;
use uucore::checksum::perform_checksum_validation;
use uucore::checksum::ChecksumError;
use uucore::checksum::ChecksumOptions;
use uucore::checksum::ChecksumVerbose;
use uucore::checksum::HashAlgorithm;
use uucore::error::{FromIo, UResult};
use uucore::sum::{Digest, Sha3_224, Sha3_256, Sha3_384, Sha3_512, Shake128, Shake256};
Expand Down Expand Up @@ -240,13 +241,14 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
|| iter::once(OsStr::new("-")).collect::<Vec<_>>(),
|files| files.map(OsStr::new).collect::<Vec<_>>(),
);

let verbose = ChecksumVerbose::new(status, quiet, warn);

let opts = ChecksumOptions {
binary,
ignore_missing,
quiet,
status,
strict,
warn,
verbose,
};

// Execute the checksum validation
Expand Down Expand Up @@ -356,14 +358,16 @@ pub fn uu_app_common() -> Command {
.short('q')
.long(options::QUIET)
.help("don't print OK for each successfully verified file")
.action(ArgAction::SetTrue),
.action(ArgAction::SetTrue)
.overrides_with_all([options::STATUS, options::WARN]),
)
.arg(
Arg::new(options::STATUS)
.short('s')
.long("status")
.help("don't output anything, status code shows success")
.action(ArgAction::SetTrue),
.action(ArgAction::SetTrue)
.overrides_with_all([options::QUIET, options::WARN]),
)
.arg(
Arg::new(options::STRICT)
Expand All @@ -382,7 +386,8 @@ pub fn uu_app_common() -> Command {
.short('w')
.long("warn")
.help("warn about improperly formatted checksum lines")
.action(ArgAction::SetTrue),
.action(ArgAction::SetTrue)
.overrides_with_all([options::QUIET, options::STATUS]),
)
.arg(
Arg::new("zero")
Expand Down
Loading
Loading
0