Comments (2)
Good point, doc patch welcome or I'll get to it eventually. Brain dumping the answer here, unpolished.
You can do a case insensitive match on a case sensitive file system, though it's a bit less efficient, because it requires regexp comparisons in all path portions, instead of just those containing magic.
However, the reverse is not true; you cannot correctly do a case sensitive match on a case insensitive file system, because stat('FILE')
will succeed if file
exists, and there's no efficient and reliable way to determine the "real" canonical case across platforms.
As to "more or less results than expected": if the case sensitivity setting doesn't match the system (and the heuristic mentioned in the PR isn't triggered; for example, a case sensitive macOS fs), then if there's a file at foo/BAR
,
Foo/*
will not find a match, becausereaddir('Foo')
failsfoo/Ba*
will returnfoo/BAR
because the pattern is converted to a case insensitive regexpfoo/Bar
will not find a match.Fo*/BAR
will find the match
which, all together, is a confusing
In the other direction, where the fs is case insensitive, but we THINK it's case sensitive,
Foo/*
will find the matchfoo/Ba*
will find not the matchfoo/Bar
will find the matchFo*/BAR
will not find the match
In other words:
- incorrectly set as
nocase:true
- patterns match more than they should
- strings match less than expected
Foo
will find a match, butFo*
will not
- incorrectly set as
nocase:false
- patterns match less than they should
- Strings match more than expected
Fo*
will not find a match, butFoo
will
from node-glob.
@isaacs thank you for the quick and detailed response!
May I suggest breaking down the nocase
setting to the following:
fscase
- overrides thenode-glob
inference of the FS case sensitivity. For this setting, keep the instructionshould only be explicitly set when it is known that the filesystem's case sensitivity differs from the platform default.
. It should be pretty self- explanatory that unexpected results are to be produced whenglob
is fed misleading information. I wouldn't even bother with the examples above, as I suspect they might do more harm (confusion) than good.matchCaseSensitivity
- default to the resolvedfscase
. In case the latter is case-sensitive, allow case-insensitive matches (using the slower regex approach). In case the FS case is case-insensitive, throw an error if case-sensitive matches are requested. Again - I don't think any example is necessary, it should be clear that one can't ask the FS for something it doesn't support (if it doesn't discern between cases, you can't ask for case sensitivity in your matches).
from node-glob.
Related Issues (20)
- UNC not working in glob.sync HOT 4
- Glob behaves differently when handed a drive letter root as its directory (Windows) HOT 2
- Inconsistency when run in root drive path `/`, prefixes match with `/` HOT 3
- Update to path-scurry and glob broke npm temporarily HOT 3
- Missing Release of Resource after Effective Lifetime [Medium Severity] HOT 1
- Querry regading error HOT 1
- test failure with node.js 22 HOT 1
- Question: fix for types issue re: shelljs reference to glob types HOT 1
- Platform independent way of referring to root? HOT 1
- Node 14 support broken due to jackspeak dependency HOT 1
- v10.4.0 raised minimum required node version to 18 HOT 1
- upgrade problem HOT 3
- The newest version of glob and rimraf now is not supported for node 14 HOT 17
- 你一更新害死人了 HOT 1
- Fix the v10.4.2 - v10.4.4 releases to still support Node 16.19.1 HOT 7
- New versions no longer support node v21 HOT 3
- Support NodeJS@21 HOT 1
- Restore support for LTS versions
- atime, birthtime, mtime, and ctime are always undefined in `ignore.ignored` function. HOT 1
- [email protected]: This module is not supported, and leaks memory. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-glob.