gobwas/glob

Strange, incorrect question mark behaviour.

donatj opened this issue · 4 comments

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:

screen shot 2016-10-19 at 5 09 57 pm

Hi @donatj!
Nice catch! Sorry.
Fix will be available in 5 minutes ;-)

@donatj fixed in v0.2.1 tag and in master.

Awesome! Thank you!

@donatj thank you! 🍻