mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
cksum: handle a corner case
This commit is contained in:
parent
234f2f9508
commit
9e080a3684
2 changed files with 24 additions and 5 deletions
|
@ -377,6 +377,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
.into());
|
.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let untagged: bool = matches.get_flag(options::UNTAGGED);
|
||||||
|
let tag: bool = matches.get_flag(options::TAG);
|
||||||
|
|
||||||
|
let binary = if untagged && tag {
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
matches.get_flag(options::BINARY)
|
||||||
|
};
|
||||||
|
|
||||||
let (name, algo, bits) = detect_algo(algo_name, length);
|
let (name, algo, bits) = detect_algo(algo_name, length);
|
||||||
|
|
||||||
let output_format = if matches.get_flag(options::RAW) {
|
let output_format = if matches.get_flag(options::RAW) {
|
||||||
|
@ -392,9 +401,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
digest: algo,
|
digest: algo,
|
||||||
output_bits: bits,
|
output_bits: bits,
|
||||||
length,
|
length,
|
||||||
untagged: matches.get_flag(options::UNTAGGED),
|
untagged,
|
||||||
output_format,
|
output_format,
|
||||||
binary: matches.get_flag(options::BINARY),
|
binary,
|
||||||
};
|
};
|
||||||
|
|
||||||
match matches.get_many::<String>(options::FILE) {
|
match matches.get_many::<String>(options::FILE) {
|
||||||
|
@ -442,8 +451,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::UNTAGGED)
|
Arg::new(options::UNTAGGED)
|
||||||
.long(options::UNTAGGED)
|
.long(options::UNTAGGED)
|
||||||
.help("create a reversed style checksum, without digest type")
|
.help("create a reversed style checksum, without digest type")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue),
|
||||||
.overrides_with(options::TAG),
|
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::TAG)
|
Arg::new(options::TAG)
|
||||||
|
|
|
@ -148,7 +148,7 @@ fn test_tag_after_untagged() {
|
||||||
.arg("-a=md5")
|
.arg("-a=md5")
|
||||||
.arg("lorem_ipsum.txt")
|
.arg("lorem_ipsum.txt")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_is_fixture("md5_single_file.expected");
|
.stdout_is("cd724690f7dc61775dfac400a71f2caa lorem_ipsum.txt\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -470,6 +470,17 @@ fn test_binary_file() {
|
||||||
.arg(at.subdir.join("f"))
|
.arg(at.subdir.join("f"))
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_contains("d41d8cd98f00b204e9800998ecf8427e *");
|
.stdout_contains("d41d8cd98f00b204e9800998ecf8427e *");
|
||||||
|
|
||||||
|
// no "*" in this case
|
||||||
|
scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("--untagged")
|
||||||
|
.arg("--tag")
|
||||||
|
.arg("--binary")
|
||||||
|
.arg("--algorithm=md5")
|
||||||
|
.arg(at.subdir.join("f"))
|
||||||
|
.succeeds()
|
||||||
|
.stdout_contains("d41d8cd98f00b204e9800998ecf8427e ");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue