File: simple-query.md

package info (click to toggle)
watchman 4.9.0-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,992 kB
  • sloc: cpp: 27,459; python: 6,538; java: 3,404; php: 3,257; ansic: 2,803; javascript: 1,116; makefile: 671; ruby: 364; sh: 124; xml: 102; lisp: 4
file content (75 lines) | stat: -rw-r--r-- 2,141 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
pageid: simple-query
title: Simple Pattern Syntax
layout: docs
section: Queries
permalink: docs/simple-query.html
---

Simple patterns follow a more traditional UNIX command line approach of
using command line switches to indicate the nature of the pattern match.
When simple patterns are used, the result set unconditionally includes
all core file metadata fields.  They are described in more detail below.

## Simple Pattern syntax

Where you see `[patterns]` in the command syntax for the `find`, `since` and
`trigger` commands, we allow filename patterns that match according the
following rules:

 * We maintain an *inclusion* and an *exclusion* list.  As the arguments
   are processed we'll accumulate them in one or the other.  By default
   they are accumulated into the *inclusion* list.
 * `-X` causes any subsequent items to be placed into the *exclusion* list
 * `-I` causes any subsequent items to be placed into the *inclusion* list
 * `--` indicates the end of the set of patterns
 * `-p` indicates that the following pattern should use `pcre` as the
   expression term.  This is reset after generating the next term.
 * `-P` indicates that the following pattern should use `ipcre` as the
   expression term and perform a case insensitive match.  This is reset
   after generating the next term.
 * If neither `-p` nor `-P` were used, the generated term will use `match`
 * `!` followed by a space followed by a pattern will negate the sense of
   the pattern match generating a `not` term.

Any elements in the inclusion list will match; they are composed together
using an "anyof" term.

The inclusion list and exclusion lists are composed using the logic `(NOT
anyof exclusion) AND (anyof inclusion)`.

For example:

     '*.c'

Generates a file expression:

```json
["match", "*.c", "wholename"]
```

A list:

    '*.js' '*.css'

```json
["anyof",
  ["match", "*.js", "wholename"],
  ["match", "*.css", "wholename"]
]
```

An example of how the exclusion list syntax works:

     -X '*.c' -I '*main*'

Generates:

```json
["allof",
  ["not", ["match", "*.c", "wholename"]],
  ["match", "*main*", "wholename"]
]
```