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

Various bugs #66

Open
aiurovet opened this issue Jun 22, 2022 · 4 comments
Open

Various bugs #66

aiurovet opened this issue Jun 22, 2022 · 4 comments

Comments

@aiurovet
Copy link

aiurovet commented Jun 22, 2022

Summary (I did not check on Linux, but hopefully, matching there is case-sensitive):

  • Escaping: no check on escaped forward-slash or escape character itself in the pattern: / or \ (yes, I understand that these are weird, but still legitimate - throw an exception at least)
  • Escaping: if you support that, then any character must be escapable, and if someone wants to have a backslash as path separator, they should double that: \ (but / instead is legitimate anyway)
  • Current directory and relative paths are not considered, and if the current drive is specified, not all absolute paths match: C:\ fails to match /
  • Path separator assumed to be outside any kind of brackets
  • Crashed for complex braces like: **/{.md,src/.cs}

Details (YES = all good):

Current Directory: C:\Users\AlexIurovetski\Projects\Dabble\Dabble\bin\Debug\net6.0

Glob:  c:\a\b\..\b\*.cs
Path:  c:\a\b\c.cs
Match: -- NO --

Glob:  **/*.cs
Path:  c:\a\b\c.cs
Match: YES

Glob:  **\*.cs
Path:  c:\a\b\c.cs
Match: YES

Glob:  **.cs
Path:  c:\a\b\c.cs
Match: YES

Glob:  \**\*.cs
Path:  c:\a\b\c.cs
Match: -- NO --

Glob:  *.{cs,txt}
Path:  c:\a\b\c.cs
Match: YES

Glob:  **/{*.md,src/*.cs}
Path:  c:\a\b\c.cs
Match: -- CRASHED --

Glob:  **[/\]*.cs
Path:  c:\a\b\c.cs
Match: -- NO --
@kthompson
Copy link
Owner

What version are you using?

@aiurovet
Copy link
Author

I took the latest stable from NuGet

@kthompson
Copy link
Owner

So based on 1.1.9 and your failing test cases:


Directory traversal in glob patterns is not supported and I don't think it makes sense to do that:

Glob:  c:\a\b\..\b\*.cs
Path:  c:\a\b\c.cs
Match: -- NO --

throws GlobPatternException Unexpected character * at index 4 since the specified format is not supported.
See the README for supported expressions https://github.com/kthompson/glob#expressions

Glob:  **/{*.md,src/*.cs}
Path:  c:\a\b\c.cs
Match: -- CRASHED --

This pattern is weird. Just use / for directory pattern matching this works on Windows and Linux. In this case the pattern should be **/*.cs this will work on Windows/Mac/Linux

Glob:  **[/\]*.cs
Path:  c:\a\b\c.cs
Match: -- NO --

Roots are treated specially between windows and linux/mac. In the Mac/Linux case this would work fine but a starting / indicates a specific root. If you want to match on any drive just use **/*.cs if you want to match on a specific drive then use c:/**/*.cs(Windows) or /**/*.cs(*nix) for your pattern.

Glob:  \**\*.cs
Path:  c:\a\b\c.cs
Match: -- NO --

In addition escaping is not supported on 1.1.9. The pre-release versions have support for escaping glob characters.
Extended glob expressions are also not supported.

@aiurovet
Copy link
Author

OK. You can close the ticket.

Sorry, I forgot to check before, but today I found that the filename abc.cs matches both **.cs and **/*.cs although the latter should fail. See GNU documentation: section globstar in https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html

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

2 participants