]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
grepc, grepc.1: Add -i flag as in grep(1)
authorAlejandro Colomar <alx.manpages@gmail.com>
Sat, 21 May 2022 22:51:30 +0000 (00:51 +0200)
committerAlejandro Colomar <alx@kernel.org>
Wed, 29 Oct 2025 20:29:05 +0000 (21:29 +0100)
Also, add some symmetry between ${iflag} and ${lflag}.

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
bin/grepc
share/man/man1/grepc.1

index 7bfbadf108b4771f8fdbc54a224e28fc104cc28d..9c59c3d3c61af0b8fe676ff31658ca200f581b98 100755 (executable)
--- a/bin/grepc
+++ b/bin/grepc
@@ -5,6 +5,7 @@
 git='no';
 ext='\.[ch]$';
 FILES='.';
+iflag='';
 lflag='';
 kflag='no';
 tflag='no';
@@ -32,7 +33,7 @@ grepc_usage()
 
 grepc_parse_cmd()
 {
-       while getopts "ghklt:x:" opt; do
+       while getopts "ghiklt:x:" opt; do
                case "$opt" in
                g)
                        git='yes';
@@ -41,11 +42,14 @@ grepc_parse_cmd()
                        grepc_usage;
                        exit 0;
                        ;;
+               i)
+                       iflag='i';
+                       ;;
                k)
                        kflag='yes';
                        ;;
                l)
-                       lflag='-l';
+                       lflag='l';
                        kflag='yes';
                        ;;
                t)
@@ -131,16 +135,16 @@ grepc_find_files()
                find $FILES -type f;
        fi \
        | grep -P -- "$ext" \
-       | xargs grep -lPI -- "$1\b";
+       | xargs grep -${iflag}lPI -- "$1\b";
 }
 
 
 grepc_helper()
 {
-       xargs grep -lPI -- "$1" \
-       | xargs grep -lP -- "$2" \
+       xargs grep -${iflag}lPI -- "$1" \
+       | xargs grep -${iflag}lP -- "$2" \
        | sort \
-       | xargs pcregrep $lflag -Mn -- "$3" /dev/null \
+       | xargs pcregrep -${iflag}${lflag}Mn -- "$3" /dev/null \
        | if [ "$kflag" = 'no' ]; then
                sed -E 's/^[^: ]+:[0-9]+:/\n\n&\n/';
        else
@@ -285,8 +289,8 @@ grepc_type_typedef_struct_union_enum()
 
 grepc_type_typedef_underlying_struct_union_enum()
 {
-       xargs grep -hP "^\s*typedef\s+(struct|union|enum)\s+.*\b$1;" <"$files" \
-       | sed -E -e 's/^\s*typedef\s+//' -e "s/\s*\**\b$1;.*//" \
+       xargs grep -${iflag}hP "^\s*typedef\s+(struct|union|enum)\s+.*\b$1;" <"$files" \
+       | sed -E -e 's/^\s*typedef\s+//' -e "s/\s*\**\b$1;.*//${iflag}" \
        | sed -E -e 's/^struct\s+//' -e 's/^union\s+//' -e 's/^enum\s+//' \
        | while read -r t; do
                test "$1" != "$t" \
index 9508f681f7522c54a17554ed0358401122fbef5b..8a74fc8f7173fb93fdf5e799e9e09c1e5e5d5a5e 100644 (file)
@@ -114,6 +114,10 @@ Restrict the search to files tracked by git.
 .B \-h
 Output a help message and exit.
 .TP
+.B \-i
+Ignore case distinctions in
+.IR pattern .
+.TP
 .B \-k
 Compact (kurz) output.
 Don't print extra newlines