files=($^array_of_folders/**/*.pattern(.N)) # assuming pattern files
# have a .pattern extension
pattern="($(cat -- $files | paste -sd '|' -))"
if [[ $1 = $~pattern ]]; then
print -r -- "$1 matches $pattern"
fi
No entanto, se você quiser saber quais dos padrões correspondem, será necessário:
files=($^array_of_folders/**/*.pattern(.N))
patterns=(${(f)"$(cat -- $files)"})
matching_patterns=()
for pattern ($patterns) {
[[ $1 = $~pattern ]] && matching_patterns+=$pattern
}
print -r -- "$1 matched by $#matching_patterns patterns: $matching_patterns"