Created
September 20, 2021 15:11
-
-
Save dalin-/56bfa3352ac08bfe94363e2994bc7319 to your computer and use it in GitHub Desktop.
Simple search through a codebase for non-inclusive language
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# search-non-inclusive-language.sh | |
# Recursively search the current directory for non-inclusive language. | |
# | |
# Typical usage: | |
# cd <site>/web/modules/custom | |
# /path/to/advotools/scripts/advo/search-non-inclusive-language.sh | |
# cd <site>/web/themes/custom | |
# /path/to/advotools/scripts/advo/search-non-inclusive-language.sh | |
# | |
# If it's catching things that it shouldn't: | |
# search-non-inclusive-language.sh | grep -v "some phrase that we don't want in the report" | |
# We'll search for any words that start with these words. | |
WORDS=(white black master slave manhour man-hour manmade man-made middleman middle-man salesman) | |
implode () { | |
local separator | |
separator="$1" | |
#local foo | |
#foo=('foo bar' 'foo baz' 'bar baz') | |
local array | |
array=("${!2}") | |
local newString | |
newString="" | |
for element in "${array[@]}" | |
do | |
newString="$newString$separator$element" | |
done | |
newString="${newString:${#separator}}" | |
#echo "line $LINENO: ${newString}" | |
varReturn="$newString" | |
return 0 | |
} | |
implode "\|" WORDS[@] | |
regex="\b\($varReturn\)" | |
grep -rni --color=auto "$regex" . | |
echo 'done' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment