facebook pixelCodiga Analysis Shell Rules, severity error
BACK TO LIST

Shell rules

Bash, zsh, ksh: regardless what Shell you use, Codiga got you covered. With hundreds of rules, the Codiga Static Engine checks for any issue in your shell script and surfaces issues in your Shell codebase.

1007

Error prone
Error

Remove space after = if trying to assign a value (for empty string

1010

Error prone
Error

Use semicolon or linefeed before 'fi' (or quote to make it literal).

1012

Error prone
Error

\\r is just literal 'r' here. For carriage return

1014

Error prone
Error

Use 'if cmd; then ..' to check exit code

1078

Error prone
Error

Did you forget to close this double quoted string?

1102

Error prone
Error

Shells disambiguate $(( differently or not at all. For $(command substition)

1105

Error prone
Error

Shells disambiguate (( differently or not at all. For subshell

Learn more

1110

Error prone
Error

This is a unicode quote. Delete and retype it (or quote to make literal).

1111

Error prone
Error

This is a unicode quote. Delete and retype it (or ignore/singlequote for literal).

2010

Error prone
Error

Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames.

2011

Error prone
Error

Use 'find .. -print0 | xargs -0 ..' or 'find .. -exec .. +' to allow non-alphanumeric filenames.

2024

Error prone
Error

sudo doesn't affect redirects. Use sudo cat file | ..

2027

Error prone
Error

The surrounding quotes actually unquote this. Remove or escape them.

2033

Error prone
Error

Shell functions can't be passed to external commands.

2036

Error prone
Error

If you wanted to assign the output of the pipeline

2046

Safety
Error

Quote this to prevent word splitting.

2049

Error prone
Error

"=~ is for regex, but this looks like a glob. Use = instead."

2050

Error prone
Error

This expression is constant. Did you forget the $ on a variable?

2060

Error prone
Error

Quote parameters to tr to prevent glob expansion.

2062

Error prone
Error

Quote the grep pattern so the shell won't interpret it.

2063

Error prone
Error

Grep uses regex

2069

Error prone
Error

To redirect stdout+stderr

2086

Safety
Error

Double quote to prevent globbing and word splitting.

2087

Error prone
Error

Quote 'VS\_CMDS' to make here document expansions happen on the server side rather than on the client.

2088

Error prone
Error

Tilde does not expand in quotes. Use $HOME.

2092

Error prone
Error

Remove backticks to avoid executing output.

2093

Error prone
Error

Remove exec " if script should continue after this command."

2097

Error prone
Error

This assignment is only seen by the forked process.

2098

Error prone
Error

This expansion will not see the mentioned assignment.

2100

Error prone
Error

Use $((..)) for arithmetics

2113

Error prone
Error

function' keyword is non-standard. Use 'foo()' instead of 'function foo'.

2115

Error prone
Error

Use ${var:?}" to ensure this never expands to /usr ."

2124

Error prone
Error

Assigning an array to a string! Assign as array

2125

Error prone
Error

Brace expansions and globs are literal in assignments. Quote it or use an array.

2139

Error prone
Error

This expands when defined

2146

Error prone
Error

This action ignores everything before the -o. Use \\( \\) to group.

2156

Error prone
Error

Injecting filenames is fragile and insecure. Use parameters.

2165

Error prone
Error

This nested loop overrides the index variable of its parent.

2167

Error prone
Error

This parent loop has its index variable overridden.

2169

Error prone
Error

Not supported in dash

2171

Error prone
Error

Found trailing ] outside test. Missing [?

2172

Error prone
Error

Trapping signals by number is not well defined. Prefer signal names.

2174

Error prone
Error

When used with -p

2176

Error prone
Error

time' is undefined for pipelines. time single stage or bash -c instead.

2178

Error prone
Error

Variable was used as an array but is now assigned a string.

2179

Error prone
Error

Use array+=(item") to append items to an array."

2183

Error prone
Error

This format string has 1 variables

2184

Error prone
Error

Quote arguments to unset so they're not glob expanded.

2187

Error prone
Error

Ash scripts will be checked as Dash. Add '# shellcheck shell=dash' to silence.

2188

Error prone
Error

This redirection doesn't have a command. Move to its command (or use 'true' as no-op).

2190

Error prone
Error

Elements in associative arrays need index

2193

Error prone
Error

The arguments to this comparison can never be equal. Make sure your syntax is correct.

2194

Error prone
Error

This word is constant. Did you forget the $ on a variable?

2195

Error prone
Error

This pattern will never match the case statement's word. Double check them.

2210

Error prone
Error

This is a file redirection. Was it supposed to be a comparison or fd operation?

2211

Error prone
Error

This is a glob used as a command name. Was it supposed to be in ${..}

2213

Error prone
Error

getopts specified -v

2214

Error prone
Error

This case is not specified by getopts.

2215

Error prone
Error

This flag is used as a command name. Bad line break or missing [ .. ]?

2216

Error prone
Error

Piping to 'rm', a command that doesn't read stdin. Wrong command or missing xargs?

2217

Error prone
Error

Redirecting to 'true'

2220

Error prone
Error

Invalid flags are not handled. Add a *) case.

2221

Error prone
Error

This pattern always overrides a later one.

2222

Error prone
Error

This pattern never matches because of a previous pattern.

2226

Error prone
Error

This ln has no destination. Check the arguments

2232

Error prone
Error

Can't use sudo with builtins like cd. Did you want sudo sh -c .. instead?

2239

Best practice
Error

Ensure the shebang uses an absolute path to the interpreter

2057

Error prone
Error

Detect unknown binary operator

2041

Best practice
Error

To run as a command, use $(..) instead of '..'

1108

Code style
Error

You need a space before and after the =

2107

Best practice
Error

Instead of [ a && b ], use [ a ] && [ b ]