diff options
| -rw-r--r-- | README.md | 16 | ||||
| -rw-r--r-- | man/grab.1 | 12 | ||||
| -rw-r--r-- | src/grab.c | 10 | 
3 files changed, 19 insertions, 19 deletions
| @@ -36,8 +36,8 @@ command is optional.  For example, a pattern string may look like ‘`x/[a-z]+/ g.foo. v/bar/`’. -The available operators are ‘g’, ‘v’, ‘x’, and ‘y’.  The ‘g’ and ‘v’ -operators are filter operators, while ‘x’ and ‘y’ are selection +The available operators are ‘g’, ‘G’, ‘x’, and ‘X’.  The ‘g’ and ‘G’ +operators are filter operators, while ‘x’ and ‘X’ are selection  operators.  You probably want to begin your pattern with a selection operator.  By @@ -52,11 +52,11 @@ echo 'foo12bar34baz' | grab 'x/[0-9]+/'  # ⇒ 34  ``` -The ‘y’ operator works in reverse, selecting everything that _doesn’t_ +The ‘X’ operator works in reverse, selecting everything that _doesn’t_  match the given regex:  ```sh -echo 'foo12bar34baz' | grab 'y/[0-9]+/' +echo 'foo12bar34baz' | grab 'X/[0-9]+/'  # ⇒ foo  # ⇒ bar  # ⇒ baz @@ -64,7 +64,7 @@ echo 'foo12bar34baz' | grab 'y/[0-9]+/'  You can additionally use filter operators to keep or discard certain  results.  The ‘g’ operator will filter out any results that don’t match -the given regex, while the ‘v’ operator will do the opposite.  To select +the given regex, while the ‘G’ operator will do the opposite.  To select  all numbers that contain a ‘3’ we can thus do:  ``` sh @@ -78,7 +78,7 @@ echo 'foo12bar34baz' | grab 'x/[0-9]+/ g/3/'  Likewise to select all numbers that don’t contain a ‘3’:  ```sh -echo 'foo12bar34baz' | grab 'x/[0-9]+/ v/3/' +echo 'foo12bar34baz' | grab 'x/[0-9]+/ G/3/'  # ⇒ 12  ``` @@ -87,7 +87,7 @@ contain a ‘3’ but aren’t the specific number ‘1337’, we could do the  following:  ```sh -grab 'x/[0-9]+/ g/3/ v/^1337$/' /foo/bar +grab 'x/[0-9]+/ g/3/ G/^1337$/' /foo/bar  ``` @@ -103,7 +103,7 @@ grep '^flags' /proc/cpuinfo \  | uniq  # With Grab -grab 'x/^flags.*/ x/\w+/ v/flags/' /proc/cpuinfo \ +grab 'x/^flags.*/ x/\w+/ G/flags/' /proc/cpuinfo \  | sort \  | uniq  ``` @@ -181,29 +181,29 @@ The supported operators are as follows:  .Bl -tag -compact  .It g  Keep selections that match the given regex. -.It v +.It G  Discard selections that match the given regex.  .It x  Select everything that matches the given regex. -.It y +.It X  Select everything that doesn’t match the given regex.  .El  .Pp  An example pattern to match all numbers that contain a ‘3’ but aren’t  ‘1337’ could be -.Sq x/[0\-9]+/ g/3/ v/^1337$/ . +.Sq x/[0\-9]+/ g/3/ G/^1337$/ .  In that pattern,  .Sq x/[0\-9]+/  selects all numbers in the input,  .Sq g/3/  keeps only those matches that contain the number 3,  and -.Sq v/^1337$/ +.Sq G/^1337$/  filters out the specific number 1337.  .Pp  As you may use whichever delimiter you like, the following is also valid:  .Pp -.Dl x|[0\-9]+| g.3. v#^1337# +.Dl x|[0\-9]+| g.3. G#^1337#  .Sh ENVIRONMENT  .Bl -tag -width GRAB_COLORS  .It Ev GRAB_COLORS @@ -251,7 +251,7 @@ option is provided.  .Sh EXAMPLES  List all your systems CPU flags, sorted and without duplicates:  .Pp -.Dl $ grab 'x/^flags.*/ x/\ew+/ v/flags/' | sort | uniq +.Dl $ grab 'x/^flags.*/ x/\ew+/ G/flags/' | sort | uniq  .Pp  Search for a pattern in multiple files without printing filenames:  .Pp @@ -66,7 +66,7 @@ typedef void (*put_func)(struct sv, regmatch_t *, const char *);  static void cmdg(struct sv, struct ops, size_t, const char *);  static void cmdx(struct sv, struct ops, size_t, const char *); -static void cmdy(struct sv, struct ops, size_t, const char *); +static void cmdX(struct sv, struct ops, size_t, const char *);  static void putm(struct sv, regmatch_t *, const char *);  static void putm_nc(struct sv, regmatch_t *, const char *); @@ -95,9 +95,9 @@ static struct {  static const cmd_func op_table[UCHAR_MAX] = {  	['g'] = cmdg, -	['v'] = cmdg, +	['G'] = cmdg,  	['x'] = cmdx, -	['y'] = cmdy, +	['X'] = cmdX,  };  static void @@ -324,7 +324,7 @@ cmdg(struct sv sv, struct ops ops, size_t i, const char *filename)  	struct op op = ops.buf[i];  	r = regexec(&op.pat, sv.p, 1, &rm, REG_STARTEND); -	if ((r == REG_NOMATCH && op.c == 'g') || (r != REG_NOMATCH && op.c == 'v')) +	if ((r == REG_NOMATCH && op.c == 'g') || (r != REG_NOMATCH && op.c == 'G'))  		return;  	if (i + 1 == ops.len) @@ -366,7 +366,7 @@ cmdx(struct sv sv, struct ops ops, size_t i, const char *filename)  }  void -cmdy(struct sv sv, struct ops ops, size_t i, const char *filename) +cmdX(struct sv sv, struct ops ops, size_t i, const char *filename)  {  	regmatch_t rm = {  		.rm_so = 0, |