Fix glob ? wildcard in non-final path segments#1242
Merged
nfischer merged 1 commit intoshelljs:mainfrom Feb 14, 2026
Merged
Conversation
fast-glob's dependency glob-parent does not recognize the ? wildcard when it appears in non-final path segments (e.g. test/r?sources/file.txt). It incorrectly treats "test/r?sources" as a literal directory name, causing the glob to fail silently and return no matches. Work around this by converting standalone ? characters to the equivalent character class [^/] before passing patterns to fast-glob. Both match exactly one non-slash character, but glob-parent correctly handles [^/]. The conversion preserves ? inside character classes ([?]), escaped characters (\?), and extglob patterns (?(...)). Un-skip the existing test for this case and add new test coverage. Fixes shelljs#1197
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1242 +/- ##
==========================================
- Coverage 97.52% 97.09% -0.43%
==========================================
Files 36 36
Lines 1493 1514 +21
==========================================
+ Hits 1456 1470 +14
- Misses 37 44 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
nfischer
approved these changes
Feb 14, 2026
Member
nfischer
left a comment
There was a problem hiding this comment.
Wow, thanks so much for fixing this!
Member
|
Let me know if you'd also like to contribute unit tests to cover the special cases in your code (handling |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1197
The
?wildcard stopped working in non-final path segments after the switch tofast-globin v0.9.0. For example:Root cause
fast-globusesglob-parentto determine the base directory for filesystem walking.glob-parentcorrectly identifies*as a glob character but fails to recognize?in non-final path segments. So fortest/r?sources/file1.txt, it returnstest/r?sourcesas the base directory (a non-existent path), and the glob returns no matches.Fix
Before passing patterns to
fast-glob, convert standalone?characters to the equivalent character class[^/]. Both match exactly one non-slash character, butglob-parenthandles[^/]correctly and returns the right base directory.The conversion is careful to preserve:
?inside character classes (e.g.[?]for literal?)?(e.g.\?)?(...))Testing
?in directory names, combined with*, and?in both directory and file segments