From b904f36636902da8e10832153b9cc4db2cae531c Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 2 Jun 2025 22:30:59 +0200 Subject: [PATCH] l10n: manages aliases of commands --- src/bin/coreutils.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/bin/coreutils.rs b/src/bin/coreutils.rs index 384ac9876..a910f8a16 100644 --- a/src/bin/coreutils.rs +++ b/src/bin/coreutils.rs @@ -51,6 +51,23 @@ fn name(binary_path: &Path) -> Option<&str> { binary_path.file_stem()?.to_str() } +fn get_canonical_util_name(util_name: &str) -> &str { + match util_name { + // uu_test aliases - '[' is an alias for test + "[" => "test", + + // hashsum aliases - all these hash commands are aliases for hashsum + "md5sum" | "sha1sum" | "sha224sum" | "sha256sum" | "sha384sum" | "sha512sum" + | "sha3sum" | "sha3-224sum" | "sha3-256sum" | "sha3-384sum" | "sha3-512sum" + | "shake128sum" | "shake256sum" | "b2sum" | "b3sum" => "hashsum", + + "dir" => "ls", // dir is an alias for ls + + // Default case - return the util name as is + _ => util_name, + } +} + #[allow(clippy::cognitive_complexity)] fn main() { uucore::panic::mute_sigpipe_panic(); @@ -71,6 +88,7 @@ fn main() { // binary name equals prefixed util name? // * prefix/stem may be any string ending in a non-alphanumeric character + // For example, if the binary is named `uu_test`, it will match `test` as a utility. let util_name = if let Some(util) = utils.keys().find(|util| { binary_as_util.ends_with(*util) && !binary_as_util[..binary_as_util.len() - (*util).len()]