Basic

Help as the tool answering about itself

The help is not written by hand. The help is read from the same lists the tool reads, and one source is why the help cannot be wrong about the tool.

What you will see

3. The set is printed, which is what a script writer reads.

About 1 min of reading

Try It

Prove the help is one source

1

Print the names

printf 'file\nmax\nsort\n' > /tmp/h.txt; comm -12 /tmp/h.txt /tmp/n.txt | wc -l

Before you run it, say out loud what it will print. Then open the answer.

What it prints
3. The same list is what makes the help and the tool agree.
2

Print the defaults

grep -f -m 1 'max' /tmp/d.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
max 20. The default is read from one file, not copied.
3

Print the exit set

wc -l < /tmp/e.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
3. The set is printed, which is what a script writer reads.

Data Flow

The tool to its own help
1 The names are read from the tool
↓
2 The defaults are read from one file
↓
3 The exit set is printed
↓
4 The help changes nothing
Why this works
Why the help never changes the tool

The help reads and writes only. Reading only is what makes asking for help a run that changes nothing.

The one thing the help must print

The exit set. A set that is not printed is a set a script writer guesses.

Examples

The help prints the names

The names the tool takes. The same list is what makes the help and the tool agree.

The help prints the defaults

The defaults from one file. One file is what makes the help print the truth rather than a copy.

The help is a run

A run that answers about itself. A run is what a test checks, and a checked help is a help that is not a document.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← Exit codes as a written set
Previous Lesson
Exit codes as a written set
Next Lesson
Flags as a table with a short and a long name
Flags as a table with a short and a long name →