published Issues of the project Shellcheck 0.9 , developing a static analysis system of shell scripts that supports the identification of errors in scripts taking into account the features of Bash, SH, KSH and Dash. The project code is written in Haskell and is distributed under the GPLV3 license. Components are provided for integration with VIM, EMACS, VSCODE, SUBLIME, Atom and various integrated media that support GCC-compatible output of error information.
/center>
The identification of both syntactic errors in the code that leads to the conclusion by the interpreter at the time of execution, and semantic problems are supported, due to which the execution is not violated, but anomalies arise in the behavior of the script. The analyzer can also determine narrow places, non -obvious problems and pitfalls, which can lead to malfunctions in a certain set of circumstances.
From the classes of the identified errors, you can note problems with the shielding of special systems and framing in quotation marks, errors in conditional expressions, incorrect use of commands, problems of time and dates, and typical syntactic errors of newcomers. For example, the absence of spaces when comparing “[[$ foo == 0]”, the presence of spaces “VAR = 42” or an indication of the symbol $ when assigning “$ foo = 42”, the use of variables without quotes “Echo $ 1”, an indication of extra squares Siberque in “tr -cd ‘[a-za-z0-9]'”,
Additionally, the conclusion of recommendations on improving the code style, eliminate problems with tolerance and increase the reliability of the scripts. For example, instead of “echo $ [1+2]” it will be proposed to use the syntax “$ ((..))”, the design of ‘rm -rf ”$ steamroot/”*’ will be marked as an unsafe and capable of removing the root catalog when the variable is not executed $ Steamroot, and the use of “Echo {1..10}” will be highlighted as incompatible with Dash and SH.
In the new version:
- Added a warning for expressions of the type ‘Local Readonly Foo’.
- Added a warning about the inaccessibility of teams.
- Added a warning about reverse links in ‘Declare x = 1 y = $ x’.
- A warning is added if $? Used to issue an echo, printf, [], [[]] and test.
- Added a recommendation to delete ((..)) inarray [((IDX))] = val.
- Added a recommendation for combining double brackets in arithmetic contexts.
- Added a recommendation to remove round brackets in the expression
a [(x+1)] = val.
] and test.