Skip to content

Commit 8258edb

Browse files
committed
[GR-32025] Guard against nil in match nodes when ** at start of pattern.
PullRequest: truffleruby/2722
2 parents 139963a + 09a7c83 commit 8258edb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

spec/ruby/core/dir/shared/glob.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,14 @@
205205
Dir.send(@method, '**/').sort.should == expected
206206
end
207207

208+
it "recursively matches any subdirectories except './' or '../' with '**/' from the base directory if that is specified" do
209+
expected = %w[
210+
nested/directory
211+
]
212+
213+
Dir.send(@method, '**/*ory', base: 'deeply').sort.should == expected
214+
end
215+
208216
ruby_version_is ''...'3.1' do
209217
it "recursively matches any subdirectories including ./ and ../ with '.**/'" do
210218
Dir.chdir("#{DirSpecs.mock_dir}/subdir_one") do

src/main/ruby/truffleruby/core/dir_glob.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def process_directory(matches, parent, entry, glob_base_dir)
181181
switched = @next.dup
182182
switched.separator = @separator
183183
else
184-
@next.process_entry entry, true, matches, parent, glob_base_dir if glob_base_dir
184+
@next.process_entry '', true, matches, parent, glob_base_dir if glob_base_dir
185185
end
186186

187187
stack = [nil]

0 commit comments

Comments
 (0)