How the wildcard ** work within fnmatch?
matching, ruby, wildcard
Solution
This behavior is actually documented, but it's easy to miss. Buried in the examples it says:
wildcard doesn't match leading period by default.
To enable this behavior, you need to specify the File::FNM_DOTMATCH flag:
File.fnmatch('**.rb', './main.rb', File::FNM_DOTMATCH)
=> true
Problem
I notice an surprising behavior of the `fnmatch` function of Ruby: ``` File.fnmatch('**.rb', 'main.rb') #=> true File.fnmatch('**.rb', './main.rb') #=> false ``` As far as being explained in the the Ruby reference, `**` will: Matches directories recursively or files expansively. So why doesn't it expands and matches `./main.rb`?