Skip to content

Latest commit

 

History

History
31 lines (21 loc) · 512 Bytes

SC1086.md

File metadata and controls

31 lines (21 loc) · 512 Bytes

Pattern: Use of $ on iterator name in for loop

Issue: -

Description

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

Further Reading