File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 11// Copyright 2018-2025 the Deno authors. MIT license.
22
3+ use std:: borrow:: Cow ;
34use std:: collections:: HashMap ;
45use std:: ffi:: OsStr ;
56use std:: ffi:: OsString ;
@@ -862,17 +863,21 @@ fn evaluate_word_parts(
862863
863864 // when globstar is disabled, replace ** with * so it doesn't match
864865 // across directory boundaries (the glob crate always treats ** as recursive)
865- let pattern_text = if !options. contains ( ShellOptions :: GLOBSTAR )
866+ let pattern_text: Cow < str > = if !options. contains ( ShellOptions :: GLOBSTAR )
866867 && current_text. contains ( "**" )
867868 {
868- // replace ** with * to disable recursive matching
869- current_text. replace ( "**" , "*" )
869+ // repeatedly replace ** with * to handle cases like *** -> ** -> *
870+ let mut result = current_text. clone ( ) ;
871+ while result. contains ( "**" ) {
872+ result = result. replace ( "**" , "*" ) ;
873+ }
874+ Cow :: Owned ( result)
870875 } else {
871- current_text . clone ( )
876+ Cow :: Borrowed ( & current_text )
872877 } ;
873878
874879 let pattern = if is_absolute {
875- pattern_text. clone ( )
880+ pattern_text. into_owned ( )
876881 } else {
877882 format ! ( "{}/{}" , cwd. display( ) , pattern_text)
878883 } ;
You can’t perform that action at this time.
0 commit comments