trans
January 22, 2026, 8:00pm
1
Ran into a small oddity with Dir.glob and how it matches dotfiles. Looked into it: not matching hidden files is standard behavior and one has to use the option dot_files to get hidden file to match. Ok. However:
This inconsistency is why **/*/.gitignore “works” - when * is followed by /, it inexplicably matches dotfiles.
I don’t think I understand what your examples are supposed to mean. I can’t understand the notation.
Could you perhaps clarify the cases in text?
trans
January 22, 2026, 11:53pm
4
Dir.glob("*") # does not match hidden paths (standard behavior)
Dir.glob("*/") # does match hidden paths
zw963
January 23, 2026, 3:35am
5
Dir.glob(“*/”) is match with sub-directory in current folder, even though it does seem a bit inconsistent, a directory is also a file technically.
Ah, gotcha
This looks like a bug, actually. */ should not match .dir/, just like * doesn’t match .file.
opened 10:40AM - 23 Jan 26 UTC
kind:bug
topic:stdlib:system
A path component starting with a wildcard in `Dir.glob` should not match a dot f… ile.
That is unless [`MatchOptions::DotFiles`](https://crystal-lang.org/api/1.19.1/File/MatchOptions.html#enum-members) is that. But that's not the case for the default behaviour (cf [`File::MatchOptions.glob_default`](https://crystal-lang.org/api/1.19.1/File/MatchOptions.html#glob_default-class-method)).
`Dir.glob("*")` works exactly like that. And `Dir.glob("*/")` should be expected to do the same. After all, it's just an additional filter to include only directories. But, `*/` does in fact match directories whose name starts with at dot:
```cr
File.touch(".file")
Dir.mkdir(".dir")
Dir.glob("*") # => []
Dir.glob("*/") # => [".dir/"] # This should be empty
```
---
Add a :+1: [reaction] to [issues you find important].
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
[issues you find important]:
https://github.com/crystal-lang/crystal/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc