Prevent globbing after variable substitution
As an alternative to switching between set -f
and set +f
you could perhaps just apply a single set -f
to a subshell since the environment of the parent shell would not by affected by this at all:
(set -ffor file in $(cat files); do command1 < "$file" echo "$file"done)# or evensh -f -c ' for file in $(cat files); do command1 < "$file" echo "$file" done'