Bash Code Guidelines

Formatters and Linters

When writing Bash code for this project, please

  • Format your code with shfmt.

    To format a file spam.sh run shfmt -ln=bash -i=4 -ci -sr -w path/to/spam.sh in a terminal.

  • Lint your code with shellcheck.

    To lint a file spam.sh run shellcheck path/to/spam.sh in a terminal. The settings to use are specified in .shellcheckrc, which is automatically read by shellcheck.

Note

The listed formatters and linters offer plugins for many popular text editors and integrated development environments (IDEs). When using these plugins, your code is formatted and linted on the fly, so you don’t have to run the commands yourself.

Note

If you have set up pre-commit, the above formatters and linters check your code before every commit.