DeveloperWiki:Bash Coding Style

This article is part of the DeveloperWiki

Outline

A policy to govern the bash coding style in PKGBUILDs, initscripts, and any other bash we write ourselves and package.

Accepted

This policy has not yet been officially accepted.

Policy

  • encoding is utf-8
  • use #!/bin/bash
  • indent with tabs
  • tabs have 4 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
else
    do something else
fi

for i in a b c; do
    echo $i
done
  • use single quotes if a string does not contain parseable content
  • use source instead of .

dissertation help