Shell

Shell

Made by DeepSource
Syntax error SH-1070
Bug risk
Critical

There's a syntax error at the highlighted location. This will cause the shell to crash with a syntax error as well.

for loop used on find output SH-2044
Bug risk
Critical

The usage of for loops over find output is fragile because it relies on word splitting and will evaluate globs. This will fail for filenames containing spaces, globbing, or regex characters and similar, such as My File.mp3, MyFile[2008].mp3. This also has a series of potential globbing issues depending on other filenames in the directory. For example: if you have MyFile2.mp3 and MyFile[2014].mp3, the former file will play twice and the latter will not play at all (because [2014] behaves as regex here, and MyFile2.mp3 will match this).

Missing space before # SH-1099
Bug risk
Major

Found a keyword immediately followed by a #. In order for the # to start a comment, it needs to come after a word boundary such as a space.

Use double quote to prevent globbing and word splitting SH-2086
Bug risk
Major

Unquoted HTML entity found SH-1109
Bug risk
Major

There is an unquoted HTML entity, such as &amp;, &gt; or &lt; (instead of &, > and <) in your code. It is recommended to replace HTML entities with their corresponding characters.

Unicode double quotes detected SH-1015
Bug risk
Major

Problematic code:

Missing space after < SH-1038
Bug risk
Critical

Detected use of <<(, which is an invalid construct. You probably meant to redirect < from process substitution <(..) instead. To do this, a space is needed between the < and <(..), i.e. < <(cmd).

Can't escape ( or ) inside [[..]] SH-1029
Anti-pattern
Major

You don't have to -- and can't -- escape ( or ) inside a [[ .. ]] expression like you do in [ .. ]. It is recommended remove the escaping.

Opening and closing brackets do not match SH-1033
Bug risk
Critical

Found a test expression [ ... ] (POSIX) or [[ ... ]] (ksh/bash) where the opening and closing brackets did not match (i.e. [[ .. ] or [ .. ]]). The brackets need to match up to work.

eof is not on a separate line SH-1042
Bug risk
Major

Found eof further down, but not on a separate line. Close matches include -eof (!= eof).

Missing fi statement here SH-1047
Bug risk
Critical

Expected fi matching previously mentioned if statement.

Single quote not escaped properly SH-1003
Bug risk
Major

Problematic code:

Empty then clause detected SH-1048
Bug risk
Major

$ used on the left side of an assignment SH-1066
Bug risk
Critical

Unlike Perl or PHP, $ is not used when assigning to a variable.

Braces are required for positionals over 9 SH-1037
Bug risk
Major

For legacy reasons, $10 is interpreted as the variable $1 followed by the literal string 0. Curly braces are needed to tell the shell that both digits are part of the parameter expansion.

Unicode single quote used SH-1016
Bug risk
Major

Problematic code:

Invalid or unescaped ( found SH-1036
Bug risk
Major

The checker expected an ordinary shell word but found an opening parenthesis instead. Determine what you intended the parenthesis to do and rewrite accordingly. Common issues include: * Wanting them to be literal, as in echo (FAIL) Some tests failed. In this case, it requires quoting.

Missing } SH-1056
Bug risk
Critical

Escaping a non-special character SH-1001
Anti-pattern
Minor

Trying to escape something that has no special meaning when escaped. The backslash will simply be ignored here. If the backslash was supposed to be literal, it is recommended to enclose it in a single quote or escape it. If you wanted it to expand to something, rewrite the expression to use printf (or in bash, $'\t').