@@ -52,24 +52,18 @@ fn main() {
5252 process:: exit ( 0 ) ;
5353 } ) ;
5454
55- // binary name equals util name?
56- if let Some ( & ( uumain , _ ) ) = utils. get ( binary_as_util ) {
57- validation :: setup_localization_or_exit ( binary_as_util ) ;
58- process :: exit ( uumain ( vec ! [ binary . into ( ) ] . into_iter ( ) . chain ( args ) ) ) ;
59- }
55+ // binary name ends with util name?
56+ let matched_util = utils
57+ . keys ( )
58+ . filter ( | & & u| binary_as_util . ends_with ( u ) && !binary_as_util . ends_with ( "coreutils" ) )
59+ . max_by_key ( |u| u . len ( ) ) ; //Prefer stty more than tty. coreutils is not ls
6060
61- // binary name equals prefixed util name?
62- // * prefix/stem may be any string ending in a non-alphanumeric character
63- // For example, if the binary is named `uu_test`, it will match `test` as a utility.
64- let util_name =
65- if let Some ( util) = validation:: find_prefixed_util ( binary_as_util, utils. keys ( ) . copied ( ) ) {
66- // prefixed util => replace 0th (aka, executable name) argument
67- Some ( OsString :: from ( util) )
68- } else {
69- // unmatched binary name => regard as multi-binary container and advance argument list
70- uucore:: set_utility_is_second_arg ( ) ;
71- args. next ( )
72- } ;
61+ let util_name = if let Some ( & util) = matched_util {
62+ Some ( OsString :: from ( util) )
63+ } else {
64+ uucore:: set_utility_is_second_arg ( ) ;
65+ args. next ( )
66+ } ;
7367
7468 // 0th argument equals util name?
7569 if let Some ( util_os) = util_name {
0 commit comments