Shell Script Interfaces
Usage Line
Explain the Interface
A usage line tells callers which command form the script accepts. It should match the names and options the script actually parses.
Program
Play the script to choose a command name and see the generated usage text.
usage_line.sh
#!/usr/bin/env bash
script_name=
usage="usage: $script_name [--dry-run] <target>"
echo "$usage"
#!/usr/bin/env bash
script_name=
usage="usage: $script_name [--dry-run] <target>"
echo "$usage"
usage
Usage text is the short contract shown when a caller needs help.
script name
Using the script name variable keeps help text reusable.
argument contract
`<target>` signals a required positional argument.