BASH / Bourne Shell which outputs its own documentation
I love Python docstrings - It's a great application of the DRY principle. The excellent Advanced Bash-Scripting Guide has an example which does something similar, but it embeds the documentation in a variable in the middle of the code. This makes it less readable and findable than ordinary comments, and leads to duplication if you want to have the same documentation as a comment for other developers. Here's a very simple solution, which I'm sure can be improved to fit your documentation style. It simply prints all non-empty lines from the start of the file:
A bit of detail: The exit code is from /usr/include/sysexits.h on Linux, which
seems to be the standard, and
< $0 passes the contents of the
current file to the while loop.
No webmentions were found.