support prefixed names (#231)

This commit is contained in:
oech3
2026-06-03 21:11:29 +09:00
committed by GitHub
parent 250f935efe
commit 58da229c09
2 changed files with 12 additions and 8 deletions
+11 -7
View File
@@ -58,7 +58,7 @@ fn main() -> ExitCode {
let exe_path = binary_path(&mut args);
let exe_name = name(&exe_path);
let util_name = if exe_name == "diffutils" {
let util_name = if exe_name.as_encoded_bytes().ends_with(b"diffutils") {
// Discard the item we peeked.
let _ = args.next();
@@ -69,13 +69,17 @@ fn main() -> ExitCode {
OsString::from(exe_name)
};
match util_name.to_str() {
Some("diff") => diff::main(args),
Some("cmp") => cmp::main(args),
Some(name) => {
eprintln!("{name}: utility not supported");
match util_name.as_encoded_bytes() {
name if name.ends_with(b"diff") => diff::main(args),
name if name.ends_with(b"cmp") => cmp::main(args),
name => {
use std::io::{stderr, Write as _};
let _ = writeln!(
stderr(),
"{}: utility not supported",
String::from_utf8_lossy(name)
);
ExitCode::from(2)
}
None => second_arg_error(exe_name),
}
}
+1 -1
View File
@@ -32,7 +32,7 @@ mod common {
"Expected utility name as second argument, got nothing.\n",
));
for subcmd in ["diff", "cmp"] {
for subcmd in ["diff", "cmp", "uu-diff", "uucmp"] {
let mut cmd = cargo_bin_cmd!("diffutils");
cmd.arg(subcmd);
cmd.arg("--foobar");