summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLieuwe Rooijakkers <lieuwerooijakkers@gmail.com>2024-08-11 00:31:34 +0200
committerLieuwe Rooijakkers <lieuwerooijakkers@gmail.com>2024-08-11 00:31:34 +0200
commit4a10b536a80af4fa3a2f5cdc7e07abda5115c680 (patch)
treefa92a39bd7626ace51c1b2f2ad11d36d7b3e4d4e /src
parentdc81049ccead5d715520623e5541da46ab38db7d (diff)
grijp: add -q
Diffstat (limited to 'src')
-rw-r--r--src/grijp.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/grijp.c b/src/grijp.c
index feb92c1..8a939f1 100644
--- a/src/grijp.c
+++ b/src/grijp.c
@@ -23,6 +23,7 @@ static bool icase = false;
static bool binary = false;
static bool list = false;
static bool invert = false;
+static bool quiet = false;
static size_t npat = 0;
static void **patterns = NULL; // can hold `char*` or `regex_t*`
@@ -44,7 +45,7 @@ static void usage(FILE *f) {
// Returns pointer to argument array containing patterns and then the file names
static char** parse_options(int argc, char **argv) {
int opt;
- while ((opt = getopt(argc, argv, "FiEUlLvhV")) != -1) {
+ while ((opt = getopt(argc, argv, "FiEUlLvqhV")) != -1) {
switch (opt) {
case 'F':
fixed = true;
@@ -68,6 +69,9 @@ static char** parse_options(int argc, char **argv) {
case 'v':
invert = true;
break;
+ case 'q':
+ quiet = true;
+ break;
case 'h':
usage(stdout);
@@ -124,6 +128,8 @@ static void compile_regexps() {
}
static void printMatch(char *fname, char *line) {
+ if (quiet) return;
+
if (list) {
printf("%s\n", fname);
return;