Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
#!/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;
files="$(mktemp -t 'grepc.XXXXXX')";
find . -type f \
- | grep -P '\.[ch]' \
+ | grep -P "$ext" \
| xargs grep -lPI "$1\b" \
>"$files";
}
grepc \- find C declarations and definitions in source code
.SH SYNOPSIS
.B grepc
-.RI [ option ]
+.RI [ option " ...]"
.I identifier
.SH DESCRIPTION
.MR grepc 1
.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;"