Bash行评论延续

时间:2012-08-28 17:31:50

标签: bash shell comments

我看到一些bash / shell注释使用了符号

#  Some comment block that starts on line 1, but then
#+ continues on line 2 with this silly plus sign.

#  And this is another comment line that is not related to the ones above

“#+”对任何类型的解析器有帮助吗(比如Doxygen风格的注释如何用于自动生成文档)?

这是一种常见做法吗?我知道,就实际的脚本执行而言,包含/排除它并没有任何损害,但我很好奇采用这种评论方式是否有好处。

1 个答案:

答案 0 :(得分:7)

根据Advanced Bash-Scripting Guide,看起来这是可以用来提高脚本中清晰度和易读性的几个comment headers之一。这个花絮出现在" Assorted Tips"指南的一部分:

  

使用专用注释标题来提高脚本的清晰度和易读性。

以下是他们在指南的示例块中列出的几个:

## Caution.
rm -rf *.zzy   ##  The "-rf" options to "rm" are very dangerous,
               ##+ especially with wild cards.

#+ Line continuation.
#  This is line 1
#+ of a multi-line comment,
#+ and this is the final line.

#* Note.

#o List item.

#> Another point of view.
while [ "$var1" != "end" ]    #> while test "$var1" != "end"

显然有些人发现这些小小的东西很有帮助,但我个人认为这样做并没有多大好处。

相关问题