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

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

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -