ruby - How the wildcard ** work within fnmatch? -


i notice surprising behavior of fnmatch function of ruby:

file.fnmatch('**.rb', 'main.rb')                    #=> true file.fnmatch('**.rb', './main.rb')                  #=> false 

as far being explained in the ruby reference, ** will:

matches directories recursively or files expansively.

so why doesn't expands , matches ./main.rb?

this behavior documented, it's easy miss. buried in examples says:

wildcard doesn't match leading period default.

to enable behavior, need specify file::fnm_dotmatch flag:

file.fnmatch('**.rb', './main.rb', file::fnm_dotmatch) => true 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

asp.net mvc - Implementing normal user/pass, Twitter & Facebook auth -