DeveloperWiki:Bash Coding Style

From ArchWiki
Revision as of 18:19, 13 February 2010 by Pierre (talk | contribs)
Jump to: navigation, search


  • encoding is utf-8
  • use #!/bin/bash
  • indent with tabs
  • tabs have 8 characters
  • don't 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 parseable content
  • use source instead of .


Add these lines at the bottom of the document to enforce our guideline:

# vim: set noexpandtab tabstop=8 shiftwidth=8 textwidth=132 autoindent
# kate: indent-mode normal; indent-width 8; tab-indents on; tab-width 8; word-wrap on; word-wrap-column 132