Onl*_*Cop 13 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
Run Code Online (Sandbox Code Playgroud)
"#+"是否对任何类型的解析器都有帮助(比如Doxygen样式的注释如何用于自动生成文档)?
这是一种常见做法吗?我知道,就实际的脚本执行而言,包含/排除它并没有任何损害,但我很好奇采用这种评论方式是否有优势.
根据Advanced Bash-Scripting Guide,它看起来像是可以用来提高脚本清晰度和易读性的几个注释标题之一.这个小窍门在指南的"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"
Run Code Online (Sandbox Code Playgroud)
显然有些人发现这些小部分有用,但我个人认为这样做并没有多大好处.