https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112020-10-25T12:16:08ZRuby Issue Tracking SystemRuby master - Bug #17283: Why does Dir.glob's ** match files in current directory?https://bugs.ruby-lang.org/issues/17283?journal_id=881482020-10-25T12:16:08ZEregon (Benoit Daloze)
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/17280">Bug #17280</a>: Dir.glob with FNM_DOTMATCH matches ".." and "." and results in duplicated entries</i> added</li></ul> Ruby master - Bug #17283: Why does Dir.glob's ** match files in current directory?https://bugs.ruby-lang.org/issues/17283?journal_id=881492020-10-25T12:23:15ZEregon (Benoit Daloze)
<ul></ul><p>Interestingly this behavior differs between Bash and Zsh:</p>
<pre><code>$ tree
.
├── dir
│ └── subfile
└── foo
$ bash
$ echo **
dir foo
$ echo **/*
dir/subfile
$ zsh -f
$ echo **
dir foo
$ echo **/*
dir dir/subfile foo
</code></pre>
<p>I think we cannot change the behavior for compatibility.</p>
<p>As a fun fact, <code>"**"</code> can even match the parent directory with <code>FNM_DOTMATCH</code> (<a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Dir.glob with FNM_DOTMATCH matches ".." and "." and results in duplicated entries (Closed)" href="https://bugs.ruby-lang.org/issues/17280">#17280</a>).</p> Ruby master - Bug #17283: Why does Dir.glob's ** match files in current directory?https://bugs.ruby-lang.org/issues/17283?journal_id=881502020-10-25T12:25:32Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Applied in changeset <a class="changeset" title="[DOC] refined "**" description in `Dir.glob` [ci skip] As same as the description for `File.fnma..." href="https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/e880d075f847ff17e1bc77301a9ed363fb40525b">git|e880d075f847ff17e1bc77301a9ed363fb40525b</a>.</p>
<hr>
<p>[DOC] refined "**" description in <code>Dir.glob</code> [ci skip]</p>
<p>As same as the description for <code>File.fnmatch</code>.<br>
[Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Why does Dir.glob's ** match files in current directory? (Closed)" href="https://bugs.ruby-lang.org/issues/17283">#17283</a>]</p> Ruby master - Bug #17283: Why does Dir.glob's ** match files in current directory?https://bugs.ruby-lang.org/issues/17283?journal_id=881542020-10-25T13:14:56Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>Eregon (Benoit Daloze) wrote in <a href="#note-2">#note-2</a>:</p>
<blockquote>
<p>Interestingly this behavior differs between Bash and Zsh:</p>
</blockquote>
<p>Bash <strong>doesn't</strong> support <code>**</code>, and it just equals <code>*</code>.</p>