Strange, incorrect question mark behaviour.
donatj opened this issue · 4 comments
donatj commented
It would appear there is an error in how question mark is handled such that the full string is no longer matched against.
Here is a bug I ran into in production
package main
import (
"log"
"github.com/gobwas/glob"
)
func main() {
x := glob.MustCompile("sta")
log.Println(x.Match("stagnation"))
x2 := glob.MustCompile("sta*")
log.Println(x2.Match("stagnation"))
x3 := glob.MustCompile("sta?")
log.Println(x3.Match("stagnation"))
x4 := glob.MustCompile("sta?n")
log.Println(x4.Match("stagnation"))
}
outputs
2016/10/19 17:13:44 false
2016/10/19 17:13:44 true
2016/10/19 17:13:44 true
2016/10/19 17:13:44 true
but I would expect
2016/10/19 17:13:44 false
2016/10/19 17:13:44 true
2016/10/19 17:13:44 false
2016/10/19 17:13:44 false
Which is how glob is handled in bash and zsh:
donatj commented
Awesome! Thank you!