MCPcopy
hub / github.com/perkeep/perkeep / isShellPatternMatch

Function isShellPatternMatch

pkg/client/config.go:544–556  ·  view source on GitHub ↗

isShellPatternMatch returns whether fullpath matches the shell pattern, as defined by http://golang.org/pkg/path/filepath/#Match. As an additional special case, when the pattern looks like a basename, the last path element of fullpath is also checked against it.

(shellPattern, fullpath string)

Source from the content-addressed store, hash-verified

542
543// isShellPatternMatch returns whether fullpath matches the shell pattern, as defined by http://golang.org/pkg/path/filepath/#Match. As an additional special case, when the pattern looks like a basename, the last path element of fullpath is also checked against it.
544func isShellPatternMatch(shellPattern, fullpath string) bool {
545 match, _ := filepath.Match(shellPattern, fullpath)
546 if match {
547 return true
548 }
549 if !strings.Contains(shellPattern, filepathSeparatorString) {
550 match, _ := filepath.Match(shellPattern, filepath.Base(fullpath))
551 if match {
552 return true
553 }
554 }
555 return false
556}
557
558// hasDirPrefix reports whether the path has the provided directory prefix.
559// Both should be absolute paths.

Callers 1

newIgnoreCheckerFunction · 0.85

Calls 2

ContainsMethod · 0.80
MatchMethod · 0.65

Tested by

no test coverage detected