Repository navigation
Releases
Releases · kenshaw/glob
v0.2.0
v0.2.0 follows upstream github.com/gobwas/glob by behavior, adds the glob syntax of the shells, and makes each match take linear time.
Changes that can change a match
- A malformed pattern is an error: an unclosed
{,[or(, a trailing\, and a pattern that is not valid UTF-8 (D8). [^...]is a negation, as[!...]is. Before, it matched^(D9).- The extended groups of bash,
?() *() +() @() !(), are on by default. A pattern that held@(as text now holds a group (D10). a*antno longer matchesant, anda/**/bno longer matchesa/bwithoutWithGlobstar(issues 51, 58, 61 and 76 of upstream).
New
- Bracket expressions follow POSIX, with named classes such as
[[:alpha:]](D9). - Brace sequences, such as
{1..10},{01..10..2}and{a..e}(D11). CompileWithwith the optionsWithSeparators,WithFoldandWithGlobstar, and the functionsNew,MatchBytesandSeparators(D13, D16, D17).- The types
PathandHost, which also unmarshal from text (D14). Quoteescapes the comma too (D15).
Speed and safety
- Each match takes time linear in the length of the input, so a glob is safe on input that you do not trust. Before,
*a*a*a*a*btook 40 seconds on 400 bytes. A group such as+(*a)can take quadratic time (D20). - A match of most patterns does not allocate. A match with
WithFolddoes not copy input that is lower case already. Compiletakes less time and fewer allocations.- Fixed faults: a
*crossed a separator when there were several separators, a separator that is not ASCII could panic, and input that is not valid UTF-8 could match wrongly.
Tests
- 2,336 test vectors from a survey of 11 glob implementations.
- Fuzz tests compare the optimized matchers with a reference matcher, and give any bytes to the compiler.
The decisions are in docs/decisions. Decisions D7 to D20 are proposed.