Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
# Defaults:
+git='no';
ext='\.[ch]$';
grepc_parse_cmd()
{
- while getopts "hx:" opt; do
+ while getopts "ghx:" opt; do
case "$opt" in
+ g)
+ git='yes';
+ ;;
h)
grepc_usage;
exit 0;
{
files="$(mktemp -t 'grepc.XXXXXX')";
- find . -type f \
+ if [ "$git" = 'yes' ]; then
+ git ls-files .;
+ else
+ find . -type f;
+ fi \
| grep -P "$ext" \
| xargs grep -lPI "$1\b" \
>"$files";
so it can be used to find complex patterns.
.SH OPTIONS
.TP
+.B \-g
+Restrict the search to files tracked by git.
+.TP
.B \-h
Output a help message and exit.
.TP
Alejandro Colomar
.ME .
.SH SEE ALSO
+.MR git-ls-files 1 ,
.MR pcregrep 1 ,
.MR pcresyntax 3 ,
.MR pcrepattern 3