Header Comment Structure
A standardized header typically includes:| Field | Purpose |
|---|---|
| Shebang | Defines the interpreter (#!/usr/bin/env bash) |
| Summary | One-line description of the script’s functionality |
| Usage | How to invoke the script, including any flags/options |
| Exit Codes | List of possible exit codes and their meanings |
| Author | Name and contact information |
With modern version control systems like Git, embedding a change history in comments is usually redundant.
Example Header
Tips for Effective Comments
- Keep lines under 80 characters for readability.
- Write comments in complete sentences where clarity is needed.
- Update comments whenever you modify related code blocks.
- Avoid over-commenting trivial code—focus on intent, not implementation.