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

Glob: support for [^...] notation #663

Closed
bpasero opened this issue Nov 6, 2017 · 4 comments
Closed

Glob: support for [^...] notation #663

bpasero opened this issue Nov 6, 2017 · 4 comments
Labels
enhancement An enhancement to the functionality of the software. help wanted Others are encouraged to work on this issue.

Comments

@bpasero
Copy link

bpasero commented Nov 6, 2017

It looks like RipGrep is already supporting the [^...] syntax for glob patterns which will match on a character-range with negation. Can the [!...] syntax also be supported for the same purpose?

From http:https://man7.org/linux/man-pages/man7/glob.7.html

An expression "[!...]" matches a single character, namely any
character that is not matched by the expression obtained by removing
the first '!' from it. (Thus, "[!]a-]" matches any single character
except ']', 'a' and '-'.)

@bpasero bpasero changed the title Glob: support for [!...] notation Glob: support for [^...] notation Nov 6, 2017
@bpasero
Copy link
Author

bpasero commented Nov 6, 2017

Sorry, I got confused. RipGrep is supporting [!...] but actually not [^...] which for example node-glob seems to support.

I am however not finding a standard that describes the [^...] syntax, so feel free to close.

@BurntSushi
Copy link
Owner

Your second comment has it right.

@okdana
Copy link
Contributor

okdana commented Nov 6, 2017

FYI, even though POSIX (2.13.1) leaves the behaviour undefined, most glob-pattern implementations actually do support [^...] in addition to [!...]. bash does; zsh does; fnmatch(3) does in most C libraries, including GNU, FreeBSD/macOS, OpenBSD, and even musl; and, perhaps most importantly, git does too.

Something worth considering?

@BurntSushi BurntSushi reopened this Nov 6, 2017
@BurntSushi
Copy link
Owner

BurntSushi commented Nov 6, 2017

@okdana Cool, I didn't know that! I'm hopeful that it is a relatively simple addition to the globset crate. It is technically a breaking change, but I think we're fine. (globset should get a semver bump at least though.)

@BurntSushi BurntSushi added enhancement An enhancement to the functionality of the software. help wanted Others are encouraged to work on this issue. labels Nov 6, 2017
okdana added a commit to okdana/ripgrep that referenced this issue Nov 16, 2017
Adds support for [^...] class negation in globs for parity with git, &al.

Fixes BurntSushi#663
BurntSushi pushed a commit that referenced this issue Nov 22, 2017
Adds support for [^...] class negation in globs for parity with git, &al.

Fixes #663
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement to the functionality of the software. help wanted Others are encouraged to work on this issue.
Projects
None yet
Development

No branches or pull requests

3 participants