Skip to content
Rushen Wang edited this page Sep 12, 2024 · 3 revisions

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

Related resources:

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

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature above to find a specific one, or see Checks.

Clone this wiki locally