veyron/lib/glob: Fix bad pattern detection
filepath.Match() never returns an error when matching against an empty
name.
This caused mounttabled to panic when it received an invalid pattern.
panic: Error in glob pattern found.
[...]
veyron.io/veyron/veyron/lib/glob.(*Glob).MatchInitialSegment(0xc20df9c920,
0xc20f1395ed, 0xd, 0xc20df9c960, 0x2)
/home/ashankar/veyron/veyron/go/src/veyron.io/veyron/veyron/lib/glob/glob.go:91 +0x152
Change-Id: Id6a184a3838643350555bbf9afed5133a216033c
diff --git a/lib/glob/glob.go b/lib/glob/glob.go
index 9551c7e..353179d 100644
--- a/lib/glob/glob.go
+++ b/lib/glob/glob.go
@@ -47,8 +47,9 @@
// The only error we can get from the filepath library is badpattern.
// A future implementation would most likely recognize that here, so for now
// I'll just check every part to make sure it's error free.
+ // Note: Match never returns an error when matching against an empty string.
for _, elem := range g.elems {
- if _, err := filepath.Match(elem, ""); err != nil {
+ if _, err := filepath.Match(elem, "test"); err != nil {
return nil, err
}
}