Pattern: Missing expansion quoting in for
loop glob
Issue: -
When iterating over globs containing expansions, you can still quote all expansions in the path to better handle whitespace and special characters.
Make sure glob characters are outside quotes. "$dir/*.txt"
will not glob expand, but "$dir"/*.txt
or "$dir"/*."$ext"
will.
Example of incorrect code:
for file in $dir/*.txt
do
echo "Found $file"
done
Example of correct code:
for file in "$dir"/*.txt
do
echo "Found $file"
done
If the variable is expected to contain globs, such as if dir="tmp/**"
in the example, you can ignore this message.