facebook pixelShell Static Analysis Rules
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.

      1008

      Code style
      Minor

      This shebang was unrecognized. Note that ShellCheck only handles sh/bash/dash/ksh.

      1068

      Code style
      Minor

      Don't put spaces around the = in assignments (or quote to make it literal).

      1083

      Code style
      Minor

      This } is literal. Check expression (missing ;/\\n?) or quote it.

      1087

      Code style
      Minor

      Use braces when expanding arrays

      1090

      Code style
      Minor

      Can't follow non-constant source. Use a directive to specify location.

      1097

      Code style
      Minor

      Unexpected ==. For assignment

      1114

      Code style
      Minor

      Remove leading spaces before the shebang.

      1117

      Code style
      Minor

      Backslash is literal in \\’". Prefer explicit escaping: "\\\\’"."

      2001

      Code style
      Minor

      See if you can use ${variable//search/replace} instead.

      2002

      Code style
      Minor

      Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.

      2004

      Code style
      Minor

      $/${} is unnecessary on arithmetic variables.

      2005

      Code style
      Minor

      Useless echo? Instead of 'echo $(cmd)'

      2007

      Code style
      Minor

      Use $((..)) instead of deprecated $[..]

      2012

      Code style
      Minor

      Use find instead of ls to better handle non-alphanumeric filenames.

      2013

      Code style
      Minor

      To read lines rather than words

      2016

      Code style
      Minor

      Expressions don't expand in single quotes

      2034

      Code style
      Minor

      START\_OF\_ROOT\_PARTITION appears unused. Verify use (or export if used externally).

      2035

      Code style
      Minor

      Use ./*glob* or -- *glob* so names with dashes won't become options.

      2038

      Code style
      Minor

      Use -print0/-0 or -exec + to allow for non-alphanumeric filenames.

      2039

      Code style
      Minor

      Undefined keyword for POSIX sh

      2043

      Code style
      Minor

      This loop will only ever run once for a constant value. Did you perhaps mean to loop over dir/*

      2044

      Code style
      Minor

      For loops over find output are fragile. Use find -exec or a while read loop.

      2045

      Code style
      Minor

      Iterating over ls output is fragile. Use globs.

      2048

      Code style
      Minor

      Use $@" (with quotes) to prevent whitespace problems."

      2053

      Code style
      Minor

      Quote the right-hand side of != in [[ ]] to prevent glob matching.

      2059

      Code style
      Minor

      Don't use variables in the printf format string. Use printf ..\%s.." "$foo"."

      2061

      Code style
      Minor

      Quote the parameter to -iname so the shell won't interpret it.

      2064

      Code style
      Minor

      Use single quotes

      2068

      Code style
      Minor

      Double quote array expansions to avoid re-splitting elements.

      2071

      Code style
      Minor

      > is for string comparisons. Use -gt instead.

      2089

      Code style
      Minor

      Quotes/backslashes will be treated literally. Use an array.

      2090

      Code style
      Minor

      Quotes/backslashes in this variable will not be respected.

      2091

      Code style
      Minor

      Remove surrounding $() to avoid executing output.

      2094

      Code style
      Minor

      Make sure not to read and write the same file in the same pipeline.

      2103

      Code style
      Minor

      Use a ( subshell ) to avoid having to cd back.

      2112

      Code style
      Minor

      function' keyword is non-standard. Delete it.

      2116

      Code style
      Minor

      Useless echo? Instead of 'cmd $(echo foo)'

      2119

      Code style
      Minor

      Use start\_mysql $@" if function's $1 should mean script's $1."

      2120

      Code style
      Minor

      A function references arguments but no argument is passed

      2121

      Code style
      Minor

      To assign a variable, do not use set

      2128

      Code style
      Minor

      Expanding an array without an index only gives the first element.

      2129

      Code style
      Minor

      Consider using { cmd1; cmd2; } >> file instead of individual redirects.

      2140

      Code style
      Minor

      Word is of the form A"B"C" (B indicated). Did you mean "ABC" or "A\\"B\\"C"?"

      2145

      Code style
      Minor

      Argument mixes string and array. Use * or separate argument.

      2148

      Code style
      Minor

      Tips depend on target shell and yours is unknown. Add a shebang.

      2153

      Code style
      Minor

      Possible misspelling: FGREP may not be assigned

      2154

      Code style
      Minor

      xtra is referenced but not assigned.

      2155

      Code style
      Minor

      Declare and assign separately to avoid masking return values.

      2162

      Code style
      Minor

      read without -r will mangle backslashes.

      2163

      Code style
      Minor

      This does not export 'atom\_env\_pair'. Remove $/${} for that

      2164

      Code style
      Minor

      Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

      2181

      Code style
      Minor

      Check exit code directly with e.g. 'if mycmd;'

      2185

      Code style
      Minor

      Some finds don't have a default path. Specify '.' explicitly.

      2186

      Code style
      Minor

      tempfile is deprecated. Use mktemp instead.

      2191

      Code style
      Minor

      The = here is literal. To assign by index

      2198

      Code style
      Minor

      Arrays don't work as operands in [ ]. Use a loop (or concatenate with * instead of @).

      2206

      Code style
      Minor

      Quote to prevent word splitting/globbing

      2207

      Code style
      Minor

      Prefer mapfile or read -a to split command output (or quote to avoid splitting).

      2209

      Code style
      Minor

      Use var=$(command) to assign output (or quote to assign string).

      2219

      Code style
      Minor

      Instead of 'let expr'

      2223

      Code style
      Minor

      This default assignment may cause DoS due to globbing. Quote it.

      2230

      Code style
      Minor

      which is a non-standard tool. Use builtin 'command -v' instead.

      2231

      Code style
      Minor

      Quote expansions in this for loop glob to prevent wordsplitting

      1039

      Code style
      Minor

      Remove indentation before end token

      Learn more