Skip to content

Commit

Permalink
added WithFailOnPatternNotExist
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatcuk committed Nov 6, 2022
1 parent 8991cfe commit de326ac
Show file tree
Hide file tree
Showing 6 changed files with 370 additions and 246 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ that if the glob pattern references a path that does not exist (such as
`nonexistent/path/*`), this is _not_ considered an IO error: it is considered a
pattern with no matches.
```go
WithFailOnPatternNotExist()
```
If passed, doublestar will abort and return `doublestar.ErrPatternNotExist` if
the pattern references a path that does not exist before any meta characters
such as `nonexistent/path/*`. Note that alts (ie, `{...}`) are expanded before
this check. In other words, a pattern such as `{a,b}/*` may fail if either `a`
or `b` do not exist but `*/{a,b}` will never fail because the star may match
nothing.
### Glob
```go
Expand Down
5 changes: 5 additions & 0 deletions doublestar.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package doublestar

import (
"errors"
"path"
)

// ErrBadPattern indicates a pattern was malformed.
var ErrBadPattern = path.ErrBadPattern

// ErrPatternNotExist indicates that the pattern passed to Glob, GlobWalk, or
// FilepathGlob references a path that does not exist.
var ErrPatternNotExist = errors.New("pattern does not exist")
Loading

0 comments on commit de326ac

Please sign in to comment.