SC1076 – ShellCheck Wiki

See this page on GitHub

Sitemap


Trying to do math? Use e.g. [ $((i/2+7)) -ge 18 ].

Problematic code:

[ i / 2 + 7 -ge 18 ]

Correct code:

[ $((i / 2 + 7)) -ge 18 ]

Rationale:

ShellCheck found a loose +*/% in a test statement. This usually happens when trying to do arithmetic in a condition, but without using the arithmetic expansion construct $((expression)).

In C, if (a+b == c) is perfectly fine, but in sh this must be written to first expand the arithmetic operation like if [ $((a+b)) = c ].

Exceptions:

None.


ShellCheck is a static analysis tool for shell scripts. This page is part of its documentation.