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
Post a Comment