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
# Copyright (c) 2017 Eric Wendelin
# Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -66,7 +68,7 @@ __gradle-generate-script-cache() {
if [[ ! $(find $cache_dir/$cache_name -mmin -$cache_ttl_mins 2>/dev/null) ]]; then
# Cache all Gradle scripts
local gradle_build_scripts=$(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | egrep -v "$script_exclude_pattern")
local gradle_build_scripts=$(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | grep -E -v "$script_exclude_pattern")
printf "%s\n" "${gradle_build_scripts[@]}" > $cache_dir/$cache_name
fi
}