eof
is not on a separate line SH-1042Found eof
further down, but not on a separate line. Close matches include -eof
(!= eof
).
#
and !
in the shebang
SH-1115The script has spaces between the #
and !
in the shebang. This is not valid. Remove the spaces so the OS can correctly recognize the file as a script.
$[..]
used SH-2007The $[..]
syntax was deprecated in Bash 2.0 and replaced with the standard $((..))
syntax from Korn shell. It is therefore recommended to use $((..))
instead.
find
instead of ls
to better handle non-alphanumeric filenames SH-2012The highlighted line in the code contains a unicode quote. It is recommended to delete and retype it if a quote was intended.
fi
statement here SH-1047Expected fi
matching previously mentioned if
statement.
!
in shebang SH-1113You appear to be specifying a shebang, but missing the bang (i.e. !
). The shebang should always be of the form #!/path/shell
.
Remove surrounding $()
to avoid executing output (or use eval
if this is intentional).
Variables that are declared but not used for anything should be removed.
expr
statement SH-2003According to POSIX: > The expr utility has a rather difficult syntax [...] In many cases, the arithmetic and string features provided as part of the shell command language are easier to use than their equivalents in expr. Newly written scripts should avoid expr in favor of the new features within the shell.
There's a syntax error at the highlighted location. This will cause the shell to crash with a syntax error as well.
By default, xargs
interprets spaces and quotes in an unsafe and unexpected way. Whenever it's used, it should be used with -0
or --null
to split on \0
bytes, and find
should be made to output \0
separated filenames. POSIX does not require find
or xargs
to support null terminators, so you can also use find -exec <command> +
.
Problematic code:
\<
to prevent it redirecting (or switch to [[ .. ]]
) SH-2073cat
SH-2002Consider using cmd < file | ..
or cmd file | ..
instead. cat
is a tool for con"cat"enating files. Reading a single file as input to a program is considered a Useless Use Of Cat (UUOC).
This error is typically seen when there are too many fi
s, done
s or esac
s , or when there's a do
or then
without a corresponding while
, for
or if
.
then
clause detected SH-1048$
used on the left side of an assignment SH-1066Unlike Perl or PHP, $
is not used when assigning to a variable.
$
to make it a literal SH-1135The script appears to be closing a double quoted string for the sole purpose of making a dollar sign $
literal. This will work, but a better way is to escape it with a backslash. This allows the double quoted string to continue uninterrupted, thereby reducing the visual noise of stopping and starting quotes in the middle of a shell word.