Shell

Shell

Made by DeepSource
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).

Whitespace detected between # and ! in the shebang SH-1115
Bug risk
Major

The 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.

Deprecated $[..] used SH-2007
Bug risk
Major

The $[..] syntax was deprecated in Bash 2.0 and replaced with the standard $((..)) syntax from Korn shell. It is therefore recommended to use $((..)) instead.

Consider using find instead of ls to better handle non-alphanumeric filenames SH-2012
Bug risk
Critical

Unicode quote detected SH-1110
Anti-pattern
Major

The highlighted line in the code contains a unicode quote. It is recommended to delete and retype it if a quote was intended.

Missing fi statement here SH-1047
Bug risk
Critical

Expected fi matching previously mentioned if statement.

Missing ! in shebang SH-1113
Bug risk
Major

You appear to be specifying a shebang, but missing the bang (i.e. !). The shebang should always be of the form #!/path/shell.

Executing output of a command SH-2091
Bug risk
Major

Remove surrounding $() to avoid executing output (or use eval if this is intentional).

Lexicographical comparison operator used for numerical comparison SH-2071
Bug risk
Critical

Unused variable SH-2034
Anti-pattern
Major

Variables that are declared but not used for anything should be removed.

Outdated expr statement SH-2003
Anti-pattern
Minor

According 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.

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.

Non-alphanumeric names may have been skipped SH-2038
Anti-pattern
Major

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> +.

Single quote not escaped properly SH-1003
Bug risk
Major

Problematic code:

Escape \< to prevent it redirecting (or switch to [[ .. ]]) SH-2073
Bug risk
Critical

Mismatched keyword SH-1089
Bug risk
Critical

This error is typically seen when there are too many fis, dones or esacs , or when there's a do or then without a corresponding while, for or if.

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.

Consider escaping $ to make it a literal SH-1135
Anti-pattern
Major

The 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.