Skip to content
Closed
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
11 changes: 10 additions & 1 deletion src/uu/hashsum/src/hashsum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
.unwrap()
.map(|s| s.as_os_str());

// clap's conflicts_with does each other. So we manually rejects --tag --text while we do --text --tag by clap.
// cksum can do it naturally by clap via --untagged dep with correct message.
if matches.get_flag(options::TEXT) && std::env::args().any(|x| x == "--tag") {
return Err(uucore::error::UUsageError::new(
1,
"--tag --text is not allowed while --text --tag works (unrecommended)".to_string(),
));
}

if check {
// No reason to allow --check with --binary/--text on Cygwin. It want to be same with Linux and --text was broken for a long time.
let verbose = ChecksumVerbose::new(status, quiet, warn);
Expand Down Expand Up @@ -262,7 +271,7 @@ pub fn uu_app_common() -> Command {
.long("tag")
.help(translate!("hashsum-help-tag"))
.action(ArgAction::SetTrue)
.conflicts_with("text"),
.overrides_with(options::TEXT),
)
.arg(
Arg::new(options::TEXT)
Expand Down
13 changes: 13 additions & 0 deletions tests/by-util/test_hashsum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,19 @@ fn test_conflicting_arg() {
.fails_with_code(1);
}

#[cfg(target_os = "linux")]
#[test]
fn test_text_tag_device() {
let scene = TestScenario::new(util_name!());

scene
.ccmd("md5sum")
.arg("--text")
.arg("--tag")
.arg("/dev/null")
.succeeds();
}

#[test]
fn test_tag() {
let scene = TestScenario::new(util_name!());
Expand Down
Loading