diff options
author | Alejandro Colomar <alx.manpages@gmail.com> | 2022-05-11 19:51:46 +0200 |
---|---|---|
committer | Alejandro Colomar <alx.manpages@gmail.com> | 2022-05-11 21:19:38 +0200 |
commit | f417552f109cff273293be848b79813ee60110b4 (patch) | |
tree | b05ff5f851a7c3b2a60dbb3e4c995157588c9130 /bin/grepc | |
parent | 4c4f042196f907f42fd06612c7037716246ae5ae (diff) |
grepc, grepc.1: -g: Add option to restrict search to files tracked by git
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Diffstat (limited to 'bin/grepc')
-rwxr-xr-x | bin/grepc | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -2,6 +2,7 @@ # Defaults: +git='no'; ext='\.[ch]$'; @@ -13,8 +14,11 @@ grepc_usage() grepc_parse_cmd() { - while getopts "hx:" opt; do + while getopts "ghx:" opt; do case "$opt" in + g) + git='yes'; + ;; h) grepc_usage; exit 0; @@ -42,7 +46,11 @@ grepc_find_files() { 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"; |