DeveloperWiki:Bash Coding Style

From ArchWiki
Jump to navigation Jump to search

Gnome-colors-add-files-to-archive.pngThis article is being considered for archiving.Gnome-colors-add-files-to-archive.png

Reason: Each Arch software project has its own coding style guidelines. (Discuss in DeveloperWiki talk:Bash Coding Style)
Note: The style on this page applies to Arch Linux software projects, not code snippets on ArchWiki articles.


  • encoding is utf-8
  • use #!/bin/bash
  • indent with tabs
  • tabs have 8 characters
  • do not use more than 132 columns
  • opening braces are top right, closing are bottom left:
foo() {
        echo bar
  • if and for statements are like this:
if true; then
        do something
        do something else
for i in a b c; do
        echo $i
  • use single quotes if a string does not contain parseable content
  • use source instead of .
  • use $() instead of ``