chore: Use grep -E / grep -F instead of egrep / fgrep (#2164)

Ensures that the -E or -F option, when used, is the first option
* i.e. grep -oE => grep -E -o

Updates _bash-it-grep to invoke grep with just the provided arguments
* This function was (and still is) unused, but decided this new functionality was actually more useful

Introduces _bash-it-fgrep to invoke grep -F

Removes type -P egrep from the _bash-it-*grep functions

For usages that were already going to be modified, use -F if appropriate
* Does not touch grep usages that may have benefited from -F, but were not otherwise considered for this PR

Adds shellcheck header to modified .bash files that didn't already have it
This commit is contained in:
David Farrell
2022-10-13 10:34:57 -07:00
committed by GitHub
parent bf2034d13d
commit 00062bfcb6
10 changed files with 36 additions and 22 deletions

View File

@@ -1,3 +1,5 @@
# shellcheck shell=bash
# Bash completion for Makefile
# Loosely adapted from http://stackoverflow.com/a/38415982/1472048
@@ -17,7 +19,7 @@ _makecomplete() {
for f in "${files[@]}" ; do
while IFS='' read -r line ; do
targets+=("$line")
done < <(grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' "$f" | cut -d':' -f1)
done < <(grep -E -o '^[a-zA-Z0-9_-]+:([^=]|$)' "$f" | cut -d':' -f1)
done
[ "${#targets[@]}" -eq 0 ] && return 0