Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect slash substitution on Windows platform #64

Closed
thbecker opened this issue May 3, 2015 · 5 comments
Closed

Incorrect slash substitution on Windows platform #64

thbecker opened this issue May 3, 2015 · 5 comments

Comments

@thbecker
Copy link

thbecker commented May 3, 2015

In minimatch.js, function Minimatch back-slash characters in the pattern get replaced by forward-slashes when running on Windows platform. This isn't necessary since glob requires that only forward-slashes are used in paths. It is also wrong because patterns can contain back-slashes. For example it breaks 'npm help npm' on Windows (no man pages are found) because help.js, line 66 uses a pattern with a back-slash that mustn't be converted to a forward-slash (which is then interpreted as a path separator and breaks the pattern).

I suggest not to convert slashes in minimatch because it would be hard to distinguish slashes in paths from slashes in patterns but to leave path conversion to the caller, e.g.
var manroot = path.resolve(__dirname, "..", "man").split("\\").join("/")
in help.js, line 59.

@yortus
Copy link

yortus commented Jul 27, 2015

Related: isaacs/node-glob#212

@ericsciple
Copy link

fyi - i've found some workarounds for escaping on Windows:
@(hello) => @(@)(hello)
+(hello) => @(+)(hello)
!(hello) => @(!)(hello)

and [ab] => [[]ab]

@ericsciple
Copy link

or a little bit simpler syntax would be [@](hello), etc

@litmit
Copy link
Contributor

litmit commented Jan 25, 2017

Forward slash in glob pattern should match both forward and back slashes in filepath on Windows!
Converting slashes in glob pattern as it does minimatch is completely erroneous way.

@isaacs
Copy link
Owner

isaacs commented Feb 15, 2022

v3 0b5dea1
v5 9104d8d

@isaacs isaacs closed this as completed Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants