いつかコンピューターで仕事をするために、Bashを学ぼうとしています。
私の明晰さと独学のコードを書く弟子を改善するために、私は一貫した「指導原則」のセットに固執しようとしています。
私が自分の「ガイドライン」を作成するとき、私は明らかに自分自身に問いかけます。代わりに確立された標準を使用すべきではないのでしょうか。
これらの他の言語が持っているものと同様に、Bashのそのような「信頼できる」リファレンスを1つ見つけることができませんでした。
- Java(http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html)Javadocツールのドキュメントコメントの書き方
- Java(http://www.oracle.com/technetwork/java/javase/documentation/codeconvtoc-136057.html)Javaプログラミング言語のコード規則
- Java(https://code.google.com/p/java-coding-standards/wiki/Introduction)GoogleJavaコーディング標準
- Python(http://www.python.org/dev/peps/pep-0008/)PEP8---Pythonコードのスタイルガイド
- Python(http://google-styleguide.googlecode.com/svn/trunk/pyguide.html)GooglePythonスタイルガイド
使用される正当な理由があるBashの同様のドキュメントへのリンクはありますか?
これが私が自分でまとめたものの種類です...しかし、特に初心者として、私は自分自身を考え出すのではなく、専門家によって書かれたガイドラインを使用するべきだと思います。多くの経験、洞察、実用性、一般的なパターン/アンチパターンの知識など。
あなたは一般的にそのような文書の有効性に異議を唱えるかもしれません、しかし何人かの人々は私が上記の箇条書きで言及したもののような著名な例をオンラインで持っているウェブのためにそれらを好まなければなりません。
################################################################################
# Coding conventions
#
# - Prefer lines of 80 characters of length or less
#
# - Perform arithmetic operations and numeric comparisons within "(( ))" blocks
# e.g. if ((42<=24+24)), ((3**3==27))
#
# - Reference variables by name, not expansion, within arithmetic evaluation
# e.g. ((i++)) rather than (($i++)), ((v+=42)) rathern than v=$(($v+42))
#
# - Prefer "[[" to "[" for conditional expressions
#
# - Prefer "[[ $s ]]" to "[[ -n $s ]]" when checking for empty strings
#
# - Document each function with at least a summary sentence. This should not
# exceed the preferred line length, be written in third person, end with a
# period and concisely describe the general utility of the function
#
# ...
# ...
# ...
#
################################################################################