Ripgrep: Glob: support for [^...] notation

Created on 6 Nov 2017  路  4Comments  路  Source: BurntSushi/ripgrep

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://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 '-'.)

enhancement help wanted

All 4 comments

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.

Your second comment has it right.

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?

@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.)

Was this page helpful?
0 / 5 - 0 ratings