33
44gitgrep ()
55{
6- local out=$( git grep -I -P -n " $1 " |
7- grep -E ' ^(bash_completion|completions(-fallback|-core)?/|test/)' |
8- grep -Ev " ^test/runLint\>${filter_out: +|$filter_out } " )
6+ local pathspecs=(' bash_completion' ' completions-fallback/'
7+ ' completions-core/' ' test/' ' bash_completion.d/' ' :!:test/runLint'
8+ ' :!:test/docker/' ' :!:test/test-cmd-list.txt' )
9+ local filter_list
10+ read -ra filter_list <<< " $filter_out"
11+ pathspecs+=(" ${filter_list[@]/#/ " :!:" } " )
12+ local out=$( git grep -I -P -n " $1 " -- " ${pathspecs[@]} " )
913 if [[ $out ]]; then
1014 printf ' ***** %s\n' " $2 "
1115 printf ' %s\n\n' " $out "
@@ -53,7 +57,7 @@ gitgrep "$cmdstart"'[ef]grep\b' \
5357# TODO: $ in sed subexpression used as an anchor (POSIX BRE optional, not in
5458# Solaris/FreeBSD)
5559
56- gitgrep ' (?<!command)' " $cmdstart " ' (grep|ls|sed|cd)(\s|$)' \
60+ filter_out= " test/fixtures/_longopt/grep--help.txt " gitgrep ' (?<!command)' " $cmdstart " ' (grep|ls|sed|cd)(\s|$)' \
5761 ' invoke grep, ls, sed, and cd through "command", e.g. "command grep"'
5862
5963gitgrep ' (?<!command)' " $cmdstart " ' (?:awk|tail)(\s|$)' \
@@ -67,12 +71,12 @@ gitgrep '@\([^()|$]+\)' \
6771
6872gitgrep ' <<<' ' herestrings use temp files, use some other way'
6973
70- filter_out=' ^( test/| bash_completion\ .sh) ' gitgrep ' \[ ' \
74+ filter_out=' test/ bash_completion.sh.in ' gitgrep ' \[ ' \
7175 ' use [[ ]] instead of [ ]'
7276
7377gitgrep " $cmdstart " ' unset [^-]' ' Explicitly specify "unset -v/-f"'
7478
75- gitgrep " $cmdstart " ' ((set|shopt)\s+[+-][a-z]+\s+posix\b|(local\s+)?POSIXLY_CORRECT\b)' \
79+ filter_out= " test/config/bashrc " gitgrep " $cmdstart " ' ((set|shopt)\s+[+-][a-z]+\s+posix\b|(local\s+)?POSIXLY_CORRECT\b)' \
7680 ' fiddling with posix mode breaks keybindings with some bash versions'
7781
7882gitgrep ' \$\{([^{}\n]|\{.*\})+/([^{}\n]|\{.*\})+/([^{}"\n]|\{.*\})*\$.*\}' \
0 commit comments