summaryrefslogtreecommitdiffstats
path: root/bin
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 /bin
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>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/grepc10
1 files changed, 7 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;
}