summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2023-11-04 21:47:44 +0100
committerAlejandro Colomar <alx@kernel.org>2023-11-05 03:14:06 +0100
commitf5a927d9b0ae426010dab41df9a2b6158699d540 (patch)
tree041eaccf8dd15a0778e4e033f83fb4032b069b9d
parente1c311881d70fcb6e91b9f3b192ccea6f118aa12 (diff)
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 <alx@kernel.org>
-rwxr-xr-xbin/grepc10
-rw-r--r--share/man/man1/grepc.13
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 .