logo

bootstrap-initrd

Linux initrd to bootstrap from a small binary seed git clone https://hacktivis.me/git/bootstrap-initrd.git
commit: 5a051c7f6418d917f0798ab4996d6ebc2d26f15c
parent fa28ca02bff6dd09f544976a49de7c50febe90c6
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue,  7 May 2024 18:36:53 +0200

grep-stub.c: Implement -q

Diffstat:

Mgrep-stub.c15+++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/grep-stub.c b/grep-stub.c @@ -28,7 +28,7 @@ static struct char_list *files; static size_t patterns_r_len = 0; static regex_t *patterns_r = NULL; -static bool fixed_str = false, invert = false, count_only = false, opt_n = false; +static bool fixed_str = false, invert = false, count_only = false, opt_n = false, quiet = false; static bool multiple_files = false; static char *(*find_substring)(const char *, const char *) = &strstr; @@ -77,13 +77,16 @@ do_grep(FILE *stream, char *filename) if(found != invert) { count++; - if(multiple_files) printf("%s:", filename); - if(opt_n) printf("%zd:", ln); - if(!count_only) printf("%s\n", line); + if(!quiet) + { + if(multiple_files) printf("%s:", filename); + if(opt_n) printf("%zd:", ln); + if(!count_only) printf("%s\n", line); + } } } - if(count_only) printf("%d\n", count); + if(!quiet && count_only) printf("%d\n", count); free(line); @@ -108,7 +111,7 @@ int main(int argc, char *argv[]) { argv0 = argv[0]; - bool opt_l = false, quiet = false; + bool opt_l = false; int regcomp_flags = REG_NOSUB; struct char_list *patterns_last = NULL;