At work, I write a lot of scripts to automate commands , like Dockerfile, GitLab CI, or just a group of commands for a specific task. In my scripts, I like to add a lot of comments to indicate what the command does or why. Sometimes I even add comments between its arguments , as some of them may not be clear. ๐ฅด
These comments may be obvious for experienced developers, but I think it can helps readers, as they might not have the same knowledge. It might even be myself in a few months or years, as I regularly switch from one language to another, depending on the project I am working on.
Unfortunately, the comments between the arguments of a multiline command differ from a shell to shell. So sometimes, I find myself looking for an example in a previous projet to comment the commands of the script I am writing. ๐
To facilitate the development of my future scripts, I decided to write this little post as my personal memo. ๐
I hope this helps you write better scripts as well! Enjoy! ๐
Bash
- Normal comments:
# Comment
- Comments between arguments:
# Comment
PowerShell
Excerpt taken from my Lint PowerShell scripts with PSScriptAnalyzer post.
- Normal comments:
# Comment
- Comments between arguments:
<# Comment #>
Top comments (0)