diff --git a/basis/globs/globs-tests.factor b/basis/globs/globs-tests.factor index 4af63c3d59..1e5728f9c6 100755 --- a/basis/globs/globs-tests.factor +++ b/basis/globs/globs-tests.factor @@ -22,6 +22,8 @@ tools.test ; { f } [ "foo" "bar" append-path "*" glob-matches? ] unit-test { t } [ "foo" "bar" append-path "*" "*" append-path glob-matches? ] unit-test +{ t } [ "foo" "bar" append-path "**/bar" glob-matches? ] unit-test +{ t } [ "foo" "bar" append-path "**/b*" glob-matches? ] unit-test { f } [ "foo" "bar" append-path "foo?bar" glob-matches? ] unit-test { t } [ "foo" "bar" append-path "fo?" "bar" append-path glob-matches? ] unit-test diff --git a/basis/globs/globs.factor b/basis/globs/globs.factor index e72cd007d6..0e83e917b6 100644 --- a/basis/globs/globs.factor +++ b/basis/globs/globs.factor @@ -9,6 +9,9 @@ IN: globs : not-path-separator ( -- sep ) os windows? R/ [^\\/\\]/ R/ [^\\/]/ ? ; foldable +: wild-path-separator ( -- sep ) + os windows? R/ [^\\/\\][\\/\\]|[^\\/\\]/ R/ [^\\/][\\/]|[^\\/]/ ? ; foldable + EBNF: Character = "\\" .:c => [[ c 1string ]] @@ -29,7 +32,8 @@ CharClass = "^"?:n Ranges:e => [[ e n [ ] when ]] AlternationBody = Concatenation:c "," AlternationBody:a => [[ a c prefix ]] | Concatenation => [[ 1array ]] -Element = "*" => [[ not-path-separator ]] +Element = "**" => [[ wild-path-separator ]] + | "*" => [[ not-path-separator ]] | "?" => [[ not-path-separator ]] | "[" CharClass:c "]" => [[ c ]] | "{" AlternationBody:b "}" => [[ b ]]