Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Bash Code Style

Generally follows

And the following rules have higher priority.

Editor Settings

  • Your editor must be able to recognize the .editorconfig file in project.
  • Shellcheck must be installed, and your editor must support it.

File naming

  • All filenames must match the regex [-_a-z0-9], except other particular files (like Dockerfile).
  • All script filenames must end with .bash.

File Header

  • For executable files, put #!/usr/bin/env bash at the top of file.
  • For .bats files, put #!/usr/bin/env bats at the top of file.
  • No shebang for non-executable files.


  • Use bats for unit testing.


  • No function key. Function declaration func() {...} is preferred over function func() {...}.