Pattern: Use of brace expansion in [[ ]]
Issue: -
Brace expansions doesn't happen in [[ ]]
. They will just be interpreted literally.
Instead, use a for
loop to iterate over values, and apply your condition to each.
Example of incorrect code:
[[ "$file" = index.{htm,html,php} ]] && echo "This is the main file"
Example of correct code:
for main in index.{htm,html,php}
do
[[ "$file" = "$main" ]] && echo "This is the main file"
done