Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash line comment continuation

I have seen some bash/shell comments use the notation

#  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

Does the "#+" help with any kind of parser (like how Doxygen-style comments are used to auto-generate documentation)?

Is this a common practice? I understand that it doesn't hurt anything to include/exclude it, as far as the actual script execution goes, but I'm curious if there are advantages to adopting this style of commenting.

like image 957
OnlineCop Avatar asked Aug 28 '12 17:08

OnlineCop


1 Answers

According to the Advanced Bash-Scripting Guide, it looks like this is one of several comment headers one can use to improve clarity and legibility in scripts. This tidbit is presented in the "Assorted Tips" section of the guide:

Use special-purpose comment headers to increase clarity and legibility in scripts.

Here are several of the ones they list in the example block from the guide:

## 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"

Apparently some people find these little bits helpful, but I personally don't see much benefit in doing it.

like image 199
Jonah Bishop Avatar answered Oct 09 '22 01:10

Jonah Bishop