From 4f9aad9a98c8c6788665b80bc0685ec1f675726e Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Sun, 18 Jan 2026 20:21:18 +0900 Subject: [PATCH] Drop find_prefixed_util --- src/common/validation.rs | 44 ---------------------------------------- 1 file changed, 44 deletions(-) diff --git a/src/common/validation.rs b/src/common/validation.rs index 057e8a9120d..f3923adb872 100644 --- a/src/common/validation.rs +++ b/src/common/validation.rs @@ -62,19 +62,6 @@ fn get_canonical_util_name(util_name: &str) -> &str { } } -/// Finds a utility with a prefix (e.g., "uu_test" -> "test") -pub fn find_prefixed_util<'a>( - binary_name: &str, - mut util_keys: impl Iterator, -) -> Option<&'a str> { - util_keys.find(|util| { - binary_name.ends_with(*util) - && binary_name.len() > util.len() // Ensure there's actually a prefix - && !binary_name[..binary_name.len() - (*util).len()] - .ends_with(char::is_alphanumeric) - }) -} - /// Gets the binary path from command line arguments /// # Panics /// Panics if the binary path cannot be determined @@ -123,35 +110,4 @@ mod tests { assert_eq!(name(Path::new("")), None); assert_eq!(name(Path::new("/")), None); } - - #[test] - fn test_find_prefixed_util() { - let utils = ["test", "cat", "ls", "cp"]; - - // Test exact prefixed matches - assert_eq!( - find_prefixed_util("uu_test", utils.iter().copied()), - Some("test") - ); - assert_eq!( - find_prefixed_util("my-cat", utils.iter().copied()), - Some("cat") - ); - assert_eq!( - find_prefixed_util("prefix_ls", utils.iter().copied()), - Some("ls") - ); - - // Test non-alphanumeric separator requirement - assert_eq!(find_prefixed_util("prefixcat", utils.iter().copied()), None); // no separator - assert_eq!(find_prefixed_util("testcat", utils.iter().copied()), None); // no separator - - // Test no match - assert_eq!(find_prefixed_util("unknown", utils.iter().copied()), None); - assert_eq!(find_prefixed_util("", utils.iter().copied()), None); - - // Test exact util name (should not match as prefixed) - assert_eq!(find_prefixed_util("test", utils.iter().copied()), None); - assert_eq!(find_prefixed_util("cat", utils.iter().copied()), None); - } }