@@ -50,28 +50,45 @@ fn get_paths_matching_glob(config: &ConfigSettings) -> Result<Vec<String>> {
5050 let mut result = Vec :: new ( ) ;
5151
5252 for pattern in & config. supplied_paths {
53- let glob_matches: Vec < _ > = glob:: glob_with ( pattern, glob_settings) ?
54- . filter_map ( |entry| match entry {
55- Ok ( path) if path. is_file ( ) => Some ( path. to_string_lossy ( ) . into_owned ( ) ) ,
56- _ => None ,
57- } )
58- . collect ( ) ;
53+ let glob_result = glob:: glob_with ( pattern, glob_settings) ;
5954
60- if glob_matches. is_empty ( ) {
61- if file_exists ( pattern) {
62- result. push ( pattern. clone ( ) ) ;
63- } else if !pattern. contains ( [ '*' , '?' , '[' , ']' ] ) {
64- let path = std:: path:: Path :: new ( pattern) ;
65- if path. exists ( ) && path. is_dir ( ) {
66- if config. debug_mode {
67- eprintln ! ( "Ignoring directory: {pattern}" ) ;
55+ match glob_result {
56+ Ok ( paths) => {
57+ let glob_matches: Vec < _ > = paths
58+ . filter_map ( |entry| match entry {
59+ Ok ( path) if path. is_file ( ) => Some ( path. to_string_lossy ( ) . into_owned ( ) ) ,
60+ _ => None ,
61+ } )
62+ . collect ( ) ;
63+
64+ if glob_matches. is_empty ( ) {
65+ if file_exists ( pattern) {
66+ result. push ( pattern. clone ( ) ) ;
67+ } else if !pattern. contains ( [ '*' , '?' , '[' , ']' ] ) {
68+ let path = std:: path:: Path :: new ( pattern) ;
69+ if path. exists ( ) && path. is_dir ( ) {
70+ if config. debug_mode {
71+ eprintln ! ( "Ignoring directory: {pattern}" ) ;
72+ }
73+ } else {
74+ return Err ( anyhow:: anyhow!( "File not found: {}" , pattern) ) ;
75+ }
6876 }
6977 } else {
70- return Err ( anyhow:: anyhow!( "File not found: {}" , pattern) ) ;
78+ result. extend ( glob_matches) ;
79+ }
80+ }
81+ Err ( _) => {
82+ // If glob fails (e.g. invalid pattern), treat as literal file
83+ if file_exists ( pattern) {
84+ result. push ( pattern. clone ( ) ) ;
85+ } else {
86+ return Err ( anyhow:: anyhow!(
87+ "File not found or invalid glob: {}" ,
88+ pattern
89+ ) ) ;
7190 }
7291 }
73- } else {
74- result. extend ( glob_matches) ;
7592 }
7693 }
7794
0 commit comments