@@ -685,8 +685,10 @@ impl Pattern {
685685 . collect ( ) ;
686686
687687 if path_parts. is_empty ( ) {
688- // Pattern is just "." or "/"
689- if self . raw == "." {
688+ // Pattern is just "." or "/" or "./"
689+ // Check the preprocessed pattern, not the raw pattern
690+ let preprocessed = preprocess_pattern ( & self . raw ) ;
691+ if preprocessed == "." {
690692 Some ( "." . to_string ( ) )
691693 } else {
692694 None
@@ -1399,10 +1401,9 @@ pub fn has_magic_in_pattern(pattern: &str, noext: bool, windows_paths_no_escape:
13991401 // Check for magic characters
14001402 match c {
14011403 '*' | '?' | '[' => return true ,
1402- // Check for extglob patterns (only + and @ trigger when followed by ()
1403- // Note: ! is NOT magic per glob's behavior
1404- // Note: * and ? are already caught above
1405- '+' | '@' if !noext && i + 1 < chars. len ( ) && chars[ i + 1 ] == '(' => {
1404+ // Check for extglob patterns when followed by (
1405+ // All extglob types: +, @, !, *, ? - but * and ? are already caught above
1406+ '+' | '@' | '!' if !noext && i + 1 < chars. len ( ) && chars[ i + 1 ] == '(' => {
14061407 return true ;
14071408 }
14081409 _ => { }
@@ -3381,8 +3382,8 @@ mod tests {
33813382 // *( and ?( are magic (because * and ? are always magic)
33823383 assert ! ( Pattern :: new( "*(a|b)" ) . has_magic( ) ) ;
33833384 assert ! ( Pattern :: new( "?(a|b)" ) . has_magic( ) ) ;
3384- // !( is NOT magic per glob 's behavior
3385- assert ! ( ! Pattern :: new( "!(a|b)" ) . has_magic( ) ) ;
3385+ // !( IS magic - it 's a valid extglob for negation
3386+ assert ! ( Pattern :: new( "!(a|b)" ) . has_magic( ) ) ;
33863387 // With noext, only + and @ lose their magic; * and ? are still magic
33873388 assert ! ( !Pattern :: with_options( "+(a|b)" , true ) . has_magic( ) ) ;
33883389 assert ! ( Pattern :: with_options( "*(a|b)" , true ) . has_magic( ) ) ;
@@ -3734,8 +3735,8 @@ mod tests {
37343735 assert ! ( has_magic_in_pattern( "+(a|b)" , false , false ) ) ;
37353736 assert ! ( has_magic_in_pattern( "@(a|b)" , false , false ) ) ;
37363737
3737- // !( is NOT magic per glob 's behavior
3738- assert ! ( ! has_magic_in_pattern( "!(a|b)" , false , false ) ) ;
3738+ // !( IS magic - it 's a valid extglob for negation
3739+ assert ! ( has_magic_in_pattern( "!(a|b)" , false , false ) ) ;
37393740
37403741 // *( and ?( are magic because * and ? are always magic
37413742 assert ! ( has_magic_in_pattern( "*(a|b)" , false , false ) ) ;
0 commit comments