Skip to content

Instantly share code, notes, and snippets.

@dalin-
Created September 20, 2021 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dalin-/56bfa3352ac08bfe94363e2994bc7319 to your computer and use it in GitHub Desktop.
Save dalin-/56bfa3352ac08bfe94363e2994bc7319 to your computer and use it in GitHub Desktop.
Simple search through a codebase for non-inclusive language
#!/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