From: Alejandro Colomar Date: Wed, 11 May 2022 17:51:46 +0000 (+0200) Subject: grepc, grepc.1: -x: Add option to edit file extension X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=16addb6c9e955ebcbc6d5e03d9bb7f7a2bdcb95b;p=thirdparty%2Fman-pages.git grepc, grepc.1: -x: Add option to edit file extension Signed-off-by: Alejandro Colomar --- diff --git a/bin/grepc b/bin/grepc index 3d78821da..0bcc11222 100755 --- a/bin/grepc +++ b/bin/grepc @@ -1,20 +1,27 @@ #!/bin/sh +# Defaults: +ext='\.[ch]$'; + + grepc_usage() { - echo "Usage: $0 [OPTION] IDENTIFIER"; + echo "Usage: $0 [OPTION ...] IDENTIFIER"; } grepc_parse_cmd() { - while getopts "h" opt; do + while getopts "hx:" opt; do case "$opt" in h) grepc_usage; exit 0; ;; + x) + ext="$OPTARG"; + ;; ?) grepc_usage >&2; exit 1; @@ -36,7 +43,7 @@ grepc_find_files() files="$(mktemp -t 'grepc.XXXXXX')"; find . -type f \ - | grep -P '\.[ch]' \ + | grep -P "$ext" \ | xargs grep -lPI "$1\b" \ >"$files"; } diff --git a/share/man/man1/grepc.1 b/share/man/man1/grepc.1 index 02fb715c2..88502a5df 100644 --- a/share/man/man1/grepc.1 +++ b/share/man/man1/grepc.1 @@ -3,7 +3,7 @@ grepc \- find C declarations and definitions in source code .SH SYNOPSIS .B grepc -.RI [ option ] +.RI [ option " ...]" .I identifier .SH DESCRIPTION .MR grepc 1 @@ -18,6 +18,13 @@ so it can be used to find complex patterns. .TP .B \-h Output a help message and exit. +.TP +.BI \-x " extension" +Restrict the search to files ending with +.IR extension . +It is interpreted as a PCRE pattern. +Default: +.RB \(dq \e.[ch]$ \(dq. .SH EXAMPLES .EX .RB \(ti/src/nginx/unit$ " grepc nxt_sprintf;"