我正在尝试学习一些 Bash,以便有一天能找到一份使用计算机的工作。
为了提高我的清晰度和门徒编写我的自学代码,我试图坚持一套一致的“指导原则”。
当我推出自己的“指南”时,我显然会问自己:我不应该使用既定标准吗?
我找不到一个这样的 Bash“权威”参考,类似于这些其他语言的参考:
- 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 ) Google Java 编码标准
- Python ( http://www.python.org/dev/peps/pep-0008/ ) PEP 8 -- Python 代码风格指南
- Python ( http://google-styleguide.googlecode.com/svn/trunk/pyguide.html ) 谷歌 Python 风格指南
是否有与 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
#
# ...
# ...
# ...
#
################################################################################