DeveloperWiki:Bash Coding Style: Difference between revisions
(redirect and merge to DeveloperWiki:Policies#Bash coding style) Tag: New redirect |
(Undo revision 552840 by Larivact (talk) Alad deleted DeveloperWiki:Policies and forgot to restore this) Tags: Removed redirect Undo |
||
Line 1: | Line 1: | ||
[[Category:Arch development]] | |||
{{Note|The style on this page applies to Arch Linux software projects, not code snippets on ArchWiki articles.}} | |||
== Policy == | |||
* encoding is utf-8 | |||
* use {{ic|#!/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: | |||
<pre> | |||
foo() { | |||
echo bar | |||
} | |||
</pre> | |||
* {{ic|if}} and {{ic|for}} statements are like this: | |||
<pre> | |||
if true; then | |||
do something | |||
else | |||
do something else | |||
fi | |||
</pre> | |||
<pre> | |||
for i in a b c; do | |||
echo $i | |||
done | |||
</pre> | |||
* use single quotes if a string does not contain parseable content | |||
* use {{ic|source}} instead of {{ic|.}} | |||
* use {{ic|$()}} instead of {{ic|``}} |
Revision as of 13:00, 10 November 2018
Note: The style on this page applies to Arch Linux software projects, not code snippets on ArchWiki articles.
Policy
- 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
andfor
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.
- use
$()
instead of``