コンテンツにスキップ

「DeveloperWiki:Bash コーディングスタイル」の版間の差分

提供: ArchWiki
削除された内容 追加された内容
前書きの訳出
5行目: 5行目:
== ポリシー ==
== ポリシー ==


* encoding is utf-8
* エンコードは utf-8
* use {{ic|#!/bin/bash}}
* {{ic|#!/bin/bash}} を使う
* タブでインデントする
* indent with tabs
* タブの幅は8文字とする
* tabs have 8 characters
* 行の長さを132 文字以下にする
* do not use more than 132 columns
* 開きかっこは同じ行に、閉じかっこは単独の行に置く
* opening braces are top right, closing are bottom left:
<pre>
<pre>
foo() {
foo() {
16行目: 16行目:
}
}
</pre>
</pre>
* {{ic|if}} and {{ic|for}} statements are like this:
* {{ic|if}} {{ic|for}} 構文は以下のように書く
<pre>
<pre>
if true; then
if true; then
29行目: 29行目:
done
done
</pre>
</pre>
* 文字列が展開可能な内容を含まない場合はシングルクオートを使う
* use single quotes if a string does not contain parseable content
* use {{ic|source}} instead of {{ic|.}}
* {{ic|.}} の代わりに {{ic|source}} を使う
* use {{ic|$()}} instead of {{ic|``}}
* {{ic|``}} の代わりに {{ic|$()}} を使う

2020年5月8日 (金) 10:55時点における版

ノート このページのスタイルは Arch Linux ソフトウェアプロジェクトに適用されるもので、ArchWiki ページのコードスニペットに適用されるものではありません。

ポリシー

  • エンコードは utf-8
  • #!/bin/bash を使う
  • タブでインデントする
  • タブの幅は8文字とする
  • 行の長さを132 文字以下にする
  • 開きかっこは同じ行に、閉じかっこは単独の行に置く
foo() {
        echo bar
}
  • iffor 構文は以下のように書く
if true; then
        do something
else
        do something else
fi
for i in a b c; do
        echo $i
done
  • 文字列が展開可能な内容を含まない場合はシングルクオートを使う
  • . の代わりに source を使う
  • `` の代わりに $() を使う