From f5a927d9b0ae426010dab41df9a2b6158699d540 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Sat, 4 Nov 2023 21:47:44 +0100 Subject: bin/grepc, grepc.1: -h: Add option to suppress prefixing file names Equivalent to grep(1)'s -h, except that we always default to -H behavior. Signed-off-by: Alejandro Colomar --- bin/grepc | 10 +++++++--- share/man/man1/grepc.1 | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/grepc b/bin/grepc index f403092..1807c38 100755 --- a/bin/grepc +++ b/bin/grepc @@ -3,6 +3,7 @@ # Defaults: c='no'; +h='H'; i=''; l=''; k='no'; @@ -39,11 +40,14 @@ grepc_err() grepc_parse_cmd() { - while getopts "ciklt:" opt; do + while getopts "chiklt:" opt; do case "$opt" in c) c='yes'; ;; + h) + h='h'; + ;; i) i='i'; ;; @@ -232,11 +236,11 @@ grepc_search() grepc_patterns "$identifier" >"$patterns"; if test -z "$files"; then - pcre2grep -${i}${l}HMn -f "$patterns"; + pcre2grep -${h}${i}${l}HMn -f "$patterns"; else find $files -type f \ | xargs grep -${i}lPI -- "$identifier" \ - | xargs pcre2grep -${i}${l}HMn -f "$patterns"; + | xargs pcre2grep -${h}${i}${l}HMn -f "$patterns"; fi; } diff --git a/share/man/man1/grepc.1 b/share/man/man1/grepc.1 index fad8c88..0e01781 100644 --- a/share/man/man1/grepc.1 +++ b/share/man/man1/grepc.1 @@ -129,6 +129,9 @@ Only uses .RB ( u\fI*\fP ) are highlighted. .TP +.B \-h +Suppress the prefixing of file names on output. +.TP .B \-i Ignore case distinctions in .IR pattern . -- cgit v1.2.3