mirror of
https://github.com/uutils/diffutils.git
synced 2026-06-10 15:48:59 -07:00
support prefixed names (#231)
This commit is contained in:
+11
-7
@@ -58,7 +58,7 @@ fn main() -> ExitCode {
|
|||||||
let exe_path = binary_path(&mut args);
|
let exe_path = binary_path(&mut args);
|
||||||
let exe_name = name(&exe_path);
|
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.
|
// Discard the item we peeked.
|
||||||
let _ = args.next();
|
let _ = args.next();
|
||||||
|
|
||||||
@@ -69,13 +69,17 @@ fn main() -> ExitCode {
|
|||||||
OsString::from(exe_name)
|
OsString::from(exe_name)
|
||||||
};
|
};
|
||||||
|
|
||||||
match util_name.to_str() {
|
match util_name.as_encoded_bytes() {
|
||||||
Some("diff") => diff::main(args),
|
name if name.ends_with(b"diff") => diff::main(args),
|
||||||
Some("cmp") => cmp::main(args),
|
name if name.ends_with(b"cmp") => cmp::main(args),
|
||||||
Some(name) => {
|
name => {
|
||||||
eprintln!("{name}: utility not supported");
|
use std::io::{stderr, Write as _};
|
||||||
|
let _ = writeln!(
|
||||||
|
stderr(),
|
||||||
|
"{}: utility not supported",
|
||||||
|
String::from_utf8_lossy(name)
|
||||||
|
);
|
||||||
ExitCode::from(2)
|
ExitCode::from(2)
|
||||||
}
|
}
|
||||||
None => second_arg_error(exe_name),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ mod common {
|
|||||||
"Expected utility name as second argument, got nothing.\n",
|
"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");
|
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||||
cmd.arg(subcmd);
|
cmd.arg(subcmd);
|
||||||
cmd.arg("--foobar");
|
cmd.arg("--foobar");
|
||||||
|
|||||||
Reference in New Issue
Block a user