sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit 763409841f36041e3c143f949919d0adaf83c5bc
parent e565522068410c57707592a3f1586381865ab69c
Author: Connor Lane Smith <cls@lubutu.com>
Date:   Sat Jun  4 11:57:31 +0100

grep -E
Diffstat:
grep.1 | 5++++-
grep.c | 8+++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/grep.1 b/grep.1 @@ -3,7 +3,7 @@ grep \- search files for a pattern .SH SYNOPSIS .B grep -.RB [ \-cilnqv ] +.RB [ \-Ecilnqv ] .I pattern .RI [ file ...] .SH DESCRIPTION @@ -17,6 +17,9 @@ The status code is 0 if any lines match, and 1 if not. If an error occurred the status code is 2. .SH OPTIONS .TP +.B \-E +matches using extended regex. +.TP .B \-c prints only a count of matching lines. .TP diff --git a/grep.c b/grep.c @@ -8,6 +8,7 @@ static void grep(FILE *, const char *, regex_t *); +static bool Eflag = false; static bool iflag = false; static bool vflag = false; static bool many; @@ -22,8 +23,11 @@ main(int argc, char *argv[]) regex_t preg; FILE *fp; - while((c = getopt(argc, argv, "cilnqv")) != -1) + while((c = getopt(argc, argv, "Ecilnqv")) != -1) switch(c) { + case 'E': + Eflag = true; + break; case 'c': case 'l': case 'n': @@ -43,6 +47,8 @@ main(int argc, char *argv[]) fprintf(stderr, "usage: %s [-cilnqv] pattern [files...]\n", argv[0]); exit(2); } + if(Eflag) + flags |= REG_EXTENDED; if(iflag) flags |= REG_ICASE; regcomp(&preg, argv[optind++], flags);