]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
grepc: Allow a pattern to start with '-'
authorAlejandro Colomar <alx.manpages@gmail.com>
Sat, 14 May 2022 23:53:26 +0000 (01:53 +0200)
committerAlejandro Colomar <alx@kernel.org>
Wed, 29 Oct 2025 20:29:03 +0000 (21:29 +0100)
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
bin/grepc

index ad4bccd0c2d372d097ee0f4efa5302d9451dfef4..55758fd143117413f5119359093024265c672fbc 100755 (executable)
--- a/bin/grepc
+++ b/bin/grepc
@@ -132,18 +132,18 @@ grepc_find_files()
        else
                find $FILES -type f;
        fi \
-       | grep -P "$ext" \
-       | xargs grep -lPI "$1\b" \
+       | grep -P -- "$ext" \
+       | xargs grep -lPI -- "$1\b" \
        >"$files";
 }
 
 
 grepc_helper()
 {
-       xargs grep -lPI "$1" <"$files" \
-       | xargs grep -lP  "$2" \
+       xargs grep -lPI -- "$1" <"$files" \
+       | xargs grep -lP -- "$2" \
        | sort \
-       | xargs pcregrep $lflag -Mn "$3" /dev/null \
+       | xargs pcregrep $lflag -Mn -- "$3" /dev/null \
        | if [ "$kflag" = 'no' ]; then
                sed -E 's/^[^: ]+:[0-9]+:/\n\n&\n/';
        else