Skip to content
Open
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
18 changes: 11 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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),
}
}
Loading