shellexp3
Match string against a cruft filter pattern
Usage
extern int shellexp(const char *string, const char *pattern);
Overview
The shellexp() function is similar to fnmatch(3), but works with cruft patterns instead of standard glob(7) patterns. The function returns a true value if string matches the cruft pattern pattern, and a false value (0) otherwise. Returns -1 in case of pattern syntax error.
Cruft patterns are similar to glob(7) patterns, but are not fully compatible. The following special characters are supported:
- ? (a question mark)
-
matches exactly one character of string other than a slash.
- *
-
matches zero or more characters of string other than a slash.
- /** or /**/
-
matches zero or more path components in string. Please note that you can only use ** when directly following a slash, and furthermore, only when either directly preceding a slash or at the very end of pattern. A ** followed by anything other than a slash makes pattern invalid. A ** following anything else than a slash reduces it to having the same effect as *.
- [character-class]
-
Matches any character between the brackets exactly once. Named character classes are NOT supported. If the first character of the class is ! or ^, then the meaning is inverted (matches any character NOT listed between the brackets). If you want to specify a literal closing bracket in the class, then specify it as the first (or second, if you want to negate) character after the opening bracket. Also, simple ASCII-order ranges are supported using a dash character (see examples section).
Any other character matches itself.
Examples
|
matches |
|---|---|
|
matches all of the following: |
|
matches |
Releases
7 releases since Debian 5.0 (Lenny); the text changed 2 times.