53 lines
1.5 KiB
Bash
Executable file
53 lines
1.5 KiB
Bash
Executable file
#!/bin/bash
|
|
#set -euo pipefail
|
|
#set -x
|
|
|
|
# Define keyword categories
|
|
CRITICAL="ALERT|ATTENTION|CAUTION|CRITICAL|DANGER|SECURITY"
|
|
WARNING="BUG|DEPRECATED|FIXME|HACK|TASK|TBD|TODO|WARNING"
|
|
NOTICE="INFO|NOTE|NOTICE|TEST|TESTING"
|
|
|
|
# Colors
|
|
RED='\033[31m'
|
|
YELLOW='\033[33m'
|
|
GREY='\033[90m'
|
|
RESET='\033[0m'
|
|
|
|
# Files and directories to exclude
|
|
EXCLUDE_FILES="*.bin *.exe keywords.sh"
|
|
EXCLUDE_DIRS=".git dist android addons"
|
|
|
|
# Function to search and display results
|
|
search_keywords() {
|
|
local category=$1
|
|
local keywords=$2
|
|
local color=$3
|
|
|
|
# Build exclusion parameters for grep
|
|
exclude_args=""
|
|
for dir in $EXCLUDE_DIRS; do
|
|
exclude_args="$exclude_args --exclude-dir=$dir"
|
|
done
|
|
for file in $EXCLUDE_FILES; do
|
|
exclude_args="$exclude_args --exclude=$file"
|
|
done
|
|
|
|
# Search and format results
|
|
grep -rnI -E "$keywords" --color=never $exclude_args . | awk -v color="$color" -v reset="$RESET" -v category="$category" '
|
|
{
|
|
# Extract filename, line number, and content
|
|
split($0, parts, ":");
|
|
filename = parts[1];
|
|
linenum = parts[2];
|
|
content = substr($0, length(filename) + length(linenum) + 3);
|
|
|
|
# Format and colorize output
|
|
printf("%s%s:L%s - %s%s\n", color, filename, linenum, content, reset);
|
|
}'
|
|
}
|
|
|
|
# Run searches
|
|
echo "Searching for keywords in the repository..."
|
|
search_keywords "Critical" "$CRITICAL" "$RED"
|
|
search_keywords "Warning" "$WARNING" "$YELLOW"
|
|
search_keywords "Notice" "$NOTICE" "$GREY"
|