Skip to content

Commit

Permalink
Do not get words part of other words
Browse files Browse the repository at this point in the history
  • Loading branch information
adriaandotcom authored Oct 24, 2024
1 parent eeb66dd commit d3c758f
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@

set -eu -o pipefail

# Remove spaces from the comma separated string
# Remove spaces from the comma-separated string
QUERY_TERMS=$(echo "$INPUT_QUERY" | sed 's/, /,/g')

# Convert comma separated string to pipe separated string
# Convert comma-separated string to pipe-separated string
EXCLUDE_FOLDERS=$(echo "$INPUT_EXCLUDE" | sed -E 's/, ?/|/g')

# Set found to 0
found=0

# Loop through all files in the repo
for file in $(find . -type f | grep -vE "$EXCLUDE_FOLDERS"); do

# Split the query terms into an array
IFS=',' read -ra terms <<< "$QUERY_TERMS"
# Split the query terms into an array outside the loop for efficiency
IFS=',' read -ra terms <<< "$QUERY_TERMS"

# Loop through the array
# Loop through all files in the repo
find . -type f | grep -vE "$EXCLUDE_FOLDERS" | while read -r file; do
# Loop through the array of forbidden terms
for term in "${terms[@]}"; do

# If the term is found in the file, set found to 1
if grep -q "$term" "$file"; then
# If the term is found as a whole word in the file, set found to 1
if grep -qw "$term" "$file"; then
echo "Found '$term' in file '$file'"
found=1
fi
Expand Down

0 comments on commit d3c758f

Please sign in to comment.