refactor: finish moving ssh-* scripts to own installers
[webi-installers/.git] / shellcheck / README.md
1 ---
2 title: ShellCheck
3 homepage: https://github.com/koalaman/shellcheck
4 tagline: |
5   ShellCheck - A shell script static analysis tool
6 ---
7
8 To update or switch versions, run `webi shellcheck@stable`, or `@vx.y.z` for a
9 specific version.
10
11 ## Cheat Sheet
12
13 > shellcheck catches rookie mistakes (and old-habits-die-hard mistakes) in bash
14
15 Also recommended by Google's
16 [Shell Style Guide](https://google.github.io/styleguide/shellguide.html)
17
18 ### How to run shellcheck from the CLI
19
20 ```bash
21 shellcheck ./script.sh
22 ```
23
24 ### How to run shellcheck in vim
25
26 `shellcheck` is
27 [supported by `vim-ale`](https://github.com/dense-analysis/ale/blob/master/supported-tools.md)
28 out-of-the-box™.
29
30 Just [install `vim-ale`](https://webinstall.dev/vim-ale) and `shellcheck` and
31 you're good to go.
32
33 ### How to run shellcheck in VS Code
34
35 See
36 [Visual Studio Marketplace: ShellCheck](https://marketplace.visualstudio.com/items?itemName=timonwong.shellcheck).
37
38 ### To use shellcheck in a build or test suite:
39
40 Simply include shellcheck in the process.
41
42 ```yaml
43 check-scripts:
44   # Fail if any of these files have warnings
45   shellcheck myscripts/*.sh
46 ```
47
48 ### How to ignore an error
49
50 You can ignore an error by putting a comment with the `SCXXXX` error code above
51 it:
52
53 ```bash
54 # shellcheck disable=<code>
55 ```
56
57 ```bash
58 # shellcheck disable=SC1004
59 NOT_AN_ERROR='Look, a literal \
60 inside of a string!'
61 ```
62
63 Complete list of `SCXXXX` error codes:
64 <https://gist.github.com/nicerobot/53cee11ee0abbdc997661e65b348f375>