Pattern: Use of $
on iterator name in for
loop
Issue: -
The variable is named var
, and can be expanded to its value with $var
.
The for
loop expects the variable's name, not its value (and the name can not be specified indirectly).
Example of incorrect code:
for $var in *
do
echo "$var"
done
Example of correct code:
for var in *
do
echo "$var"
done