Rat uses a variation on the Ant or Git exclusion syntax.
?
matches a single character. For example ‘ca?’ will match ‘cat’ and ‘can’ but not ‘call’ or the abbreviation for california (or Canada) ‘CA’.*
matches zero or more characters. For example ‘ca*’ will match ‘cat’, ‘can’, ‘call’ and the abbreviation for california (or Canada) ‘CA’.**
matches zero or more directories. For example ‘**/ca?’ will match ‘my/cat’, ‘my/can’, ‘the/cat’, ‘the/can’, ‘cat’ and ‘can’.!
reverses the meaning of the expression. Example “!ca?” will not match “cat” or “can”. See include/exclude notes below.The table below shows an example of how the *
and **
differ and interact.
foo/x/y |
b/foo |
b/foo/x |
a/b/foo |
foo |
a/b/foo/x/y |
a/b/foo/x |
foo/x |
b/foo/x/y | |
---|---|---|---|---|---|---|---|---|---|
foo |
F | F | F | F | T | F | F | F | F |
foo/* |
F | F | F | F | F | F | F | T | F |
foo/** |
T | F | F | F | T | F | F | T | F |
*/foo |
F | T | F | F | F | F | F | F | F |
*/foo/* |
F | F | T | F | F | F | F | F | F |
*/foo/** |
F | T | T | F | F | F | F | F | T |
**/foo |
F | T | F | T | T | F | F | F | F |
**/foo/* |
F | F | T | F | F | F | T | T | F |
**/foo/** |
T | T | T | T | T | T | T | T | T |
Patterns that are excluded may be superseded by patterns that are included.
For example: the exclusion pattern ‘ca*’ used in conjunction with the include ‘cat’ would result in the file ‘cat’ being included but ‘can’, ‘call’ and the abbreviation for california (or Canada) ‘CA’ being excluded.
When processed a negated exclusion results in an inclusion, and a negated inclusion results in an exclusion.
Once a file is explicitly included it can not be excluded.
Patterns may use either ‘/’ or ‘\’ as the path separation character. ‘/’ is recommended.
The case sensitivity of the matching patterns depends upon the file system in use. If the file is case-sensitive then the matches are case-sensitive.