3 SC1138
Rushen Wang edited this page 2024-09-12 09:57:35 +08:00

Remove spaces between (( in arithmetic for loop.

Problematic code:

for( (i=0; i<10; i++) ); do echo $i; done

Correct code:

for((i=0; i<10; i++)); do echo $i; done

Rationale:

ShellCheck finds arithmetic for ((;;)) expressions where (( or )) are intervening with spaces

Exceptions:

None

  • Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!