Lesson 8 | Documenting the script |
Objective | Explain the importance of documenting the scripts you write. |
Documenting Shell Script
Several times I have said that others may be using your scripts, and that you might be using your own script long after you can
remember how you wrote it or why. For both reasons, it is important to document your work. This documentation can take several forms, as described in the following sections.
Include comments
Include online help
Most scripts require parameters of some sort, such as a filename or URL. When a script is started without any parameters, it should print a usage message to the screen. This message describes the script’s purpose (in one or two lines), and how the script should be launched, such as the command line options or types of files that are expected. This information is similar to the comments
within the script, but is available for those who don’t know enough about shell scripting to look at the script itself.
Write documentation
For complex scripts that perform important functions within an organization, consider writing “real” documentation, separate from the script itself. This may be an HTML file or other online help, or a few pages in a word processor. The purpose of the documentation is to help new users of the script know how to use it correctly, and to help the organization track what resources
are at its disposal.
In the next lesson, we will wrap up this module.
Documenting Shell Script - Exercise