File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,9 @@ fn main() {
127127 }
128128 usage ( & utils, binary_as_util) ;
129129 process:: exit ( 0 ) ;
130+ } else if util. starts_with ( '-' ) {
131+ // Argument looks like an option but wasn't recognized
132+ validation:: unrecognized_option ( binary_as_util, & util_os) ;
130133 } else {
131134 validation:: not_found ( & util_os) ;
132135 }
Original file line number Diff line number Diff line change @@ -29,6 +29,16 @@ pub fn not_found(util: &OsStr) -> ! {
2929 process:: exit ( 1 ) ;
3030}
3131
32+ /// Prints an "unrecognized option" error and exits
33+ pub fn unrecognized_option ( binary_name : & str , option : & OsStr ) -> ! {
34+ eprintln ! (
35+ "{}: unrecognized option '{}'" ,
36+ binary_name,
37+ option. to_string_lossy( )
38+ ) ;
39+ process:: exit ( 1 ) ;
40+ }
41+
3242/// Sets up localization for a utility with proper error handling
3343pub fn setup_localization_or_exit ( util_name : & str ) {
3444 let util_name = get_canonical_util_name ( util_name) ;
You can’t perform that action at this time.
0 commit comments